Python:pandas_datareader asfreq

时间:2018-08-14 08:20:50

标签: python pandas

from pandas_datareader import data
import matplotlib.pyplot as plt
import seaborn; seaborn.set()

f=data.DataReader('^DJI','stooq',start=2012,end=2018)
f.head()

f2=f['Close']
f2.plot(alpha=0.5, style='-')
f2.resample('BA').mean().plot(style=':')
f2.asfreq(freq='BA').plot(style='--')
plt.legend(['input','resample','asfreq'],loc='upper left')

我尝试了这段代码,并且asfreq部分出现错误(TypeError:空'DataFrame':没有要绘制的数字数据)。怎么了

f2.head()的输出是:

Date
2018-08-13    25187.70
2018-08-10    25313.14
2018-08-09    25509.23
2018-08-08    25583.75
2018-08-07    25628.91
Name: Close, dtype: float64

0 个答案:

没有答案
相关问题