【发布时间】:2020-05-07 19:20:58
【问题描述】:
我想从 pandas df 生成数据散点图,示例如下。 我可以生成线图:
ax = df_stats.plot(x = 't', y = 't_TI_var_ws')
ax1 = ax.twinx()
df_stats.plot(x='t',y='t_TI_var_pwr',ax=ax1, color='g')
但是当我尝试使用 .scatter 绘制与散点图相同的数据时,我收到错误 KeyError: 't'
ax = df_stats.plot.scatter(x = 't', y = 't_TI_var_ws')
ax1 = ax.twinx()
df_stats.plot.scatter(x='t',y='t_TI_var_pwr',ax=ax1, color='g')
【问题讨论】:
-
如果你这样做会发生什么:
df_stats.plot(x='t',y='t_TI_var_pwr',ax=ax1, color='g', kind='scatter') -
同样的错误
KeyError: 't' -
请提供样本数据
-
@YOLO
type('t')返回'str',t在变量资源管理器中被列为datetime
标签: python pandas python-2.7 dataframe plot