I was able to plot the data using the below code:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
url = "http://real-chart.finance.yahoo.com/table.csv?s=YHOO&a=03&b=12&c=2006&d=01&e=9&f=2016&g=d&ignore=.csv"
df = pd.read_csv(url)
df.index = df["Date"]
df.sort_index(inplace=True)
df['Adj Close'].plot()
plt.show()
But now I want to calculate the rolling mean of the data and plot that. This is what I've tried:
pd.rolling_mean(df.resample("1D", fill_method="ffill"), window=3, min_periods=1)
plt.plot()
But this gives me the error:
Only valid with DatetimeIndex, TimedeltaIndex or PeriodIndex
All I want to do is plot the rolling mean of the data. Why is this happening?