【发布时间】:2018-06-23 22:25:33
【问题描述】:
我有一个每周列如下的 df。我想将我的列索引更改为时间戳。这是我的 df.columns
df.columns:
Int64Index([201601, 201602, 201603, 201604, 201605, 201606, 201607,
201608, 201609,
...],
dtype='int64', name='timeline', length=104)
df.columns[0]:
201553
我想将我的 df.columns 更改为时间戳,如下所示
df.columns:
DatetimeIndex(['2016-01-04', '2016-01-11', '2016-01-18', '2016-01-25',
'2016-02-01', '2016-02-08', '2016-02-15', '2016-02-22',
'2016-02-29'.....],
dtype='int64', name='timeline', length=104)
df.columns[0]:
Timestamp('2016-01-04 00:00:00')
底线是我的 df.columns 是 int 格式,表示 yyyyww 值。从这个 int 开始,我想将其更改为显示每周星期一日期的时间戳。请告诉我一个改变这种情况的好方法。谢谢
【问题讨论】:
标签: python pandas timestamp time-series