'isocalendar giving me some wrong week number
Here's my dataframe :
And here's my code :
week_number= []
for date in df['date']:
a_date = date
print(a_date)
dt = datetime.datetime.strptime(a_date, '%Y-%m-%d')
print(dt)
number = dt.isocalendar()[1]
print(number)
week_number.append(number)
And here's the output :
2019-11-14
2019-11-14 00:00:00
46
2019-12-17
2019-12-17 00:00:00
51
2019-12-07
2019-12-07 00:00:00
49
2019-12-14
2019-12-14 00:00:00
50
2019-12-30
2019-12-30 00:00:00
1
As you can see, the last one give me 1, why did I do wrong ?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

