Here's my data:
device_create_at
136 2014-08-27 17:29:23
245 2015-09-06 15:46:00
257 2014-09-29 22:26:34
258 2014-11-05 13:02:18
Here's my expected output
device_create_at device_create_hour
136 2014-08-27 17:29:23 2014-08-27 17
245 2015-09-06 15:46:00 2015-09-06 15
257 2014-09-29 22:26:34 2014-09-29 22
258 2014-11-05 13:02:18 2014-11-05 13
As far as I know, pandas.Series.dt.strftime can do weekly mapping, the code is like this
sheet2['device_create_week'] = sheet2['device_create_at'].dt.strftime('%Y-%V')
They use %V
for week not %W
, I try to make this hourly
sheet2['device_create_hour'] = sheet2['device_create_at'].dt.strftime('%Y-%M-%D-%H')
That is doeesn't work