<jupyter_start><jupyter_text>Rolling and Expanding<jupyter_code>import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
dataframe = pd.read_csv('walmart_stock.csv',index_col='Date',parse_dates=True)
dataframe.head()
dataframe['Close'].plot(figsize=(14,5))
# rolling with windows size of every 7 days
dataframe.rolling(7).mean().head(10)
dataframe['Open'].plot()
dataframe.rolling(window=7).mean()['Close'].plot(figsize=(15,5))
dataframe['Open'].plot()
dataframe.rolling(window=30).mean()['Close'].plot(figsize=(15,5))<jupyter_output><empty_output><jupyter_text>Expanding<jupyter_code>#specify a minimum number of periods
dataframe['Close'].expanding(min_periods=1).mean().plot(figsize=(16,5))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.17096336499321574, 'fraction_numerical': 0.027137042062415198, 'mean_word_length': 12.178571428571429, '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': '255716', 'license': 'MIT', 'n_tokens_mistral': 273, 'n_tokens_neox': 263, 'n_words': 35, 'path': 'Chapter3/Rolling and Expanding.ipynb', 'repo_name': 'chrisdcruz29/Hands-on-Python-for-Finance', 'size': '737'}