【发布时间】:2020-02-25 20:56:34
【问题描述】:
df.index
DatetimeIndex(['2019-01-25 17:00:00', '2019-01-25 17:01:00',,
'2019-01-25 17:08:00', '2019-01-25 17:09:00',
...
'2019-02-15 07:44:00', '2019-02-15 07:45:00',
'2019-02-15 07:52:00', '2019-02-15 07:53:00'],
我想使用 plt.savefig 将数字保存在循环中,并且我试图将该数字命名为该图所在小时的索引。 我每小时都在循环
for hour, i in df.groupby('index_hour'):
plt.savefig(hour+'.png',dpi=300,bbox_inches='tight')
TypeError:+ 的不支持的操作数类型:'Timestamp' 和 'str'
hour
Timestamp('2019-01-25 17:00:00')
Hour 是我要获取的 .png 文件的最终名称。谢谢。
【问题讨论】:
标签: python-3.x pandas matplotlib timestamp save