我正在尝试绘制一个包含两条线的折线图(一条用于colA,另一条用于colB)。Dataframe如下所示:
date ColA ColB
2020-1 0.91 77
2020-2 0.88 77
2020-3 0.87 77我的绘图函数如下所示:
df.set_index('date',inplace=True)
fig = df.plot(x="date",y=['ColA','ColB'],kind='line')
fig.savefig("plot1.png")我收到无法识别"date“的错误。
发布于 2020-07-16 23:15:41
由于要将date列设置为索引列,因此不能在绘图中指定date列。
只需执行以下操作:
df.set_index('date',inplace=True)
fig = df.plot(kind='line')
fig.savefig("plot1.png")https://stackoverflow.com/questions/62937751
复制相似问题