AttributeError: 'DataFrame' object has no attribute 'time'

xs = [datetime.strptime(d, '%Y/%m/%d %H:%M:') for d in dff.time]
   
#plt.plot(xs, data_on.WGEN_GnTmpDrv_avg, 'o-')
plt.figure(figsize=(20,5),dpi=50)
plt.plot(rm_skew_on,c='black')
plt.plot(rm_skew_off,c='b')
plt.axhline(new_x,ls="-",c="r")#添加水平直线
plt.axhline(new_y,ls="-",c="r")#添加水平直线
plt.title("Residual graph")
plt.xlabel('Time')
plt.ylabel('Residual')

报错:AttributeError: 'DataFrame' object has no attribute 'time'

将     :xs = [datetime.strptime(d, '%Y/%m/%d %H:%M:') for d in dff.time]
改为 :xs = [datetime.datetime.strptime(d, '%Y/%m/%d %H:%M:') for d in dff.time]

程序运行成功。

你可能感兴趣的:(python)