【发布时间】:2018-06-16 03:20:43
【问题描述】:
接收错误:轴必须将freq 设置为转换为周期
尝试从具有索引值(如 2006Q1)的 DataFrame 进行绘图时
df1 = SalesReport[['Time','Product1','Product2','Product3']]
df1['Time'] = pd.to_datetime(df1['Time'], format='%d/%m/%y')
df1 = df1.set_index('Time')
df1.index = df1.index.to_period("Q")
因此获得了所需格式的数据并对此感到满意:
Product1 Product2 Product3
Time
2005Q4 5023203.0 6718023.0 3964175.0
2006Q1 5048207.0 6735528.0 3987653.0
2006Q2 5061266.0 6742690.0 4007992.0
但现在当我尝试绘图时:
plt.plot(df1)
plt.show()
收到错误:轴必须将 freq 设置为转换为周期
绘制此类数据帧的正确方法是什么?
【问题讨论】: