Get Week Numbers On Multiple Year That Is Ready For Plotting In Pandas
Here's my data I was doing sheet2['device_create_week'] = sheet2['device_create_at'].dt.week here's the result device_create_at device_create_week 136 2014-08-27
Solution 1:
sheet2['device_create_week']=sheet2['device_create_at'].dt.year.astype(str)+'-'+sheet2['device_create_at'].dt.week.astype(str)print(sheet2)device_create_atdevice_create_week1362014-08-27 17:29:23 2014-352452015-09-06 15:46:00 2015-362572014-09-29 22:26:34 2014-402582014-11-05 13:02:18 2014-454802020-02-02 17:59:54 2020-54812020-02-02 17:59:54 2020-54822020-02-02 17:59:54 2020-5
Another solution with strftime
with V
:
sheet2['device_create_week']=sheet2['device_create_at'].dt.strftime('%Y-%V')print(sheet2)device_create_atdevice_create_week1362014-08-27 17:29:23 2014-352452015-09-06 15:46:00 2015-362572014-09-29 22:26:34 2014-402582014-11-05 13:02:18 2014-454802020-02-02 17:59:54 2020-054812020-02-02 17:59:54 2020-054822020-02-02 17:59:54 2020-05
Post a Comment for "Get Week Numbers On Multiple Year That Is Ready For Plotting In Pandas"