【发布时间】:2018-03-05 06:47:47
【问题描述】:
当我尝试散点图时,“时间”出现键错误,我如何散点图这些列?
high time
0 17.23 10:37:00
1 17.64 14:01:00
2 15.28 09:31:00
3 15.56 11:41:00
4 15.56 11:42:00
5 15.25 09:30:00
6 15.25 09:49:00
7 15.10 15:52:00
8 16.41 10:40:00
9 17.75 15:09:00
10 17.75 15:10:00
11 19.20 09:41:00
df_high.plot.scatter(x='time', y='high', c=None, s=None)
plt.show()
【问题讨论】:
-
我怀疑 dtype 没有被自动设置。请与
df['time'].dtype联系。您可能需要datetimedtype。可以使用pd.to_datetime之类的东西进行转换,或者更好地使用适当的 dtype 加载数据。
标签: python pandas matplotlib scatter-plot