<jupyter_start><jupyter_text>Dunder Data Challenge 004 - Finding the Date of the Largest Percentage Stock Price Drop In this challenge, you are given a table of closing stock prices for 10 different stocks with data going back as far as 1999. For each stock, find the date where it had its largest one-day percentage loss. The data is found in the `stocks10.csv` file with each stocks ticker symbol as a column name.<jupyter_code>import pandas as pd
stocks = pd.read_csv('../data/stocks10.csv')
stocks.head()<jupyter_output><empty_output><jupyter_text>ChallengeThere is a nice, fast solution that uses just a minimal amount of code without any loops. Can you return a Series that has the ticker symbols in the index and the date where the largest percentage price drop happened as the values. Extra challengeCan you return a DataFrame with the ticker symbol as the columns and a row for the date and another row for the percentage price drop?<jupyter_code>shifted_stocks = stocks.shift(-1)
shifted_stocks.head()
diff = (shifted_stocks.drop(columns='date')
        .sub(stocks.drop(columns='date'))
        .assign(date=shifted_stocks['date']))

diff.head()
diff.apply(lambda col: col.min() if col.name != 'date' else None)
diff.nsmallest(1, columns='MSFT')[['MSFT', 'date']].set_index('MSFT')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08774583963691376, 'fraction_numerical': 0.0113464447806354, 'mean_word_length': 5.240566037735849, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '298091', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 399, 'n_tokens_neox': 384, 'n_words': 162, 'path': 'challenges/Dunder Data Challenge 004 - Finding the Date of the Largest Percentage Stock Price Drop.ipynb', 'repo_name': 'diegoglozano/Dunder-Data-Challenges', 'size': '1322'}