在x轴上带有日期时间的熊猫图

时间:2019-02-25 16:08:52

标签: python pandas matplotlib

在23.4之前的Pandas版本中,我可以这样做:

df.plot(x=df.DateTime, y=['var1', 'var2'])   

使用df.DateTime作为日期时间类型。在v23.4中,我收到此错误:

ValueError: x must be a label or position

我已经能够根据以下主题的建议来解决此问题:plot x-axis as date in matplotlib

df = df.set_index(df.DateTime)
df.plot(y=['var1', 'var2'])   # i.e. don't specify x

我的问题:这是使用当前Pandas和Matplotlib版本处理此问题的正确方法吗?

0 个答案:

没有答案
相关问题