<jupyter_start><jupyter_text>Investor - Flow of Funds - US  Introduction:Special thanks to: https://github.com/rgrp for sharing the dataset. Step 1. Import the necessary libraries<jupyter_code>import pandas as pd
import datetime as dt<jupyter_output><empty_output><jupyter_text>Step 2. Import the dataset from this [address](https://raw.githubusercontent.com/datasets/investor-flow-of-funds-us/master/data/weekly.csv).   Step 3. Assign it to a variable called df<jupyter_code>df = pd.read_csv('https://raw.githubusercontent.com' +
                 '/datasets/investor-flow-of-funds-us/master/data/weekly.csv')
df.head()<jupyter_output><empty_output><jupyter_text>Step 4.  What is the frequency of the dataset?<jupyter_code>len(df)<jupyter_output><empty_output><jupyter_text>Step 5. Set the column Date as the index.<jupyter_code>df = df.set_index('Date')<jupyter_output><empty_output><jupyter_text>Step 6. What is the type of the index?<jupyter_code>type(df.index)<jupyter_output><empty_output><jupyter_text>Step 7. Set the index to a DatetimeIndex type<jupyter_code>df.index = pd.to_datetime(df.index)<jupyter_output><empty_output><jupyter_text>Step 8.  Change the frequency to monthly, sum the values and assign it to monthly.<jupyter_code>monthly = df.resample('M').sum()<jupyter_output><empty_output><jupyter_text>Step 9. You will notice that it filled the dataFrame with months that don't have any data with NaN. Let's drop these rows.<jupyter_code>monthly = monthly[(monthly != 0).all(axis=1)]
monthly.head()<jupyter_output><empty_output><jupyter_text>Step 10. Good, now we have the monthly data. Now change the frequency to year.<jupyter_code>yearly = monthly.resample('Y').sum()
yearly.head()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11849710982658959, 'fraction_numerical': 0.007514450867052023, 'mean_word_length': 6.429184549356223, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 37, 'https://': 3, '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': '9', 'dir': 'jupyter-structured-clean-dedup', 'id': '562151', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 619, 'n_tokens_neox': 596, 'n_words': 135, 'path': '09_Time_Series/Investor_Flow_of_Funds_US/Exercises.ipynb', 'repo_name': 'pl2599/Pandas-Exercises', 'size': '1730'}