<jupyter_start><jupyter_text>Apple Stock  Introduction:We are going to use Apple's stock price. Step 1. Import the necessary libraries<jupyter_code>import pandas as pd 
pd.__version__<jupyter_output><empty_output><jupyter_text>Step 2. Import the dataset from this [address](https://raw.githubusercontent.com/guipsamora/pandas_exercises/master/09_Time_Series/Apple_Stock/appl_1980_2014.csv)<jupyter_code>url = 'https://raw.githubusercontent.com/guipsamora/pandas_exercises/master/09_Time_Series/Apple_Stock/appl_1980_2014.csv'<jupyter_output><empty_output><jupyter_text>Step 3. Assign it to a variable apple<jupyter_code>apple = pd.read_csv(url)
apple.head()<jupyter_output><empty_output><jupyter_text>Step 4.  Check out the type of the columns<jupyter_code>apple.columns<jupyter_output><empty_output><jupyter_text>Step 5. Transform the Date column as a datetime type<jupyter_code>apple.Date = pd.to_datetime(apple.Date)<jupyter_output><empty_output><jupyter_text>Step 6.  Set the date as the index<jupyter_code>apple = apple.set_index('Date')<jupyter_output><empty_output><jupyter_text>Step 7.  Is there any duplicate dates?<jupyter_code>apple.index.is_unique<jupyter_output><empty_output><jupyter_text>Step 8.  Ops...it seems the index is from the most recent date. Make the first entry the oldest date.<jupyter_code>apple = apple[::-1]<jupyter_output><empty_output><jupyter_text>Step 9. Get the last business day of each month<jupyter_code>apple.resample('BM').mean()<jupyter_output><empty_output><jupyter_text>Step 10.  What is the difference in days between the first day and the oldest<jupyter_code>(apple.index[-1] - apple.index[0]).days<jupyter_output><empty_output><jupyter_text>Step 11.  How many months in the data we have?<jupyter_code>len(apple.resample('BM'))<jupyter_output><empty_output><jupyter_text>Step 12. Plot the 'Adj Close' value. Set the size of the figure to 13.5 x 9 inches<jupyter_code>apple['Adj Close'].plot(figsize = (13.5, 9), title = 'Apple Stock', logy = True)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11275964391691394, 'fraction_numerical': 0.02274975272007913, 'mean_word_length': 7.951327433628318, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 49, 'https://': 2, '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': '12', 'dir': 'jupyter-structured-clean-dedup', 'id': '463061', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 770, 'n_tokens_neox': 722, 'n_words': 146, 'path': '09_Time_Series/Apple_Stock/Exercises.ipynb', 'repo_name': 'society765/pandas_exercises', 'size': '2022'}