<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 
pd.__version__<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<jupyter_code>url = 'https://raw.githubusercontent.com/datasets/investor-flow-of-funds-us/master/data/weekly.csv'

wek = pd.read_csv(url)
print(wek.shape)
wek.head()<jupyter_output>(44, 9)<jupyter_text>Step 4.  What is the frequency of the dataset?<jupyter_code>wek.Date<jupyter_output><empty_output><jupyter_text>Step 5. Set the column Date as the index.<jupyter_code>if 'Date' in wek: 
    wek = wek.set_index('Date')
wek<jupyter_output><empty_output><jupyter_text>Step 6. What is the type of the index?<jupyter_code>wek.index.dtype<jupyter_output><empty_output><jupyter_text>Step 7. Set the index to a DatetimeIndex type<jupyter_code>wek.index = pd.to_datetime(wek.index)
print(wek.index.dtype)
wek<jupyter_output>datetime64[ns]<jupyter_text>Step 8.  Change the frequency to monthly, sum the values and assign it to monthly.<jupyter_code>mth = wek.resample('M').sum()
mth<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>mth = mth[mth['Total Equity']!=0]
#mth = mth.drop(mth[mth['Total Equity']==0].index)
mth<jupyter_output><empty_output><jupyter_text>Step 10. Good, now we have the monthly data. Now change the frequency to year.<jupyter_code>yrl = wek.resample('AS').sum()
yrl<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12200557103064066, 'fraction_numerical': 0.010027855153203343, 'mean_word_length': 6.546218487394958, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 35, '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': '257939', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 691, 'n_tokens_neox': 669, 'n_words': 145, 'path': '09_Time_Series/Investor_Flow_of_Funds_US/Exercises.ipynb', 'repo_name': 'society765/pandas_exercises', 'size': '1795'}