我第一次使用 matplotlib 在条形图、柱形图、折线图和散点图中可视化我的数据。每当我提到 x 和 y 轴时,我都会收到错误消息。这是我下面所有图表的代码,
df.plot.bar(pd.DatetimeIndex(df['date']), y=df[value])
df.plot.bar(pd.DatetimeIndex(df['date']), y=df[value])
df.plot.line(pd.DatetimeIndex(df['date']), y=df[value])
df.plot.scatter(x=pd.DatetimeIndex(df['date']), y=df[value])
plt.show()
我在datetime index KeyError: 'the label [2000-01-03 00:00:00] is not in the [index]'中发现了类似的问题。但这并不能解决我的问题。