Is there a better solution than df['weekofyear'] = df['date'].dt.weekofyear
?
The problem of this solution is that, sometimes, the days after the last week of the year n but before the first week of the year n+1 are counted as week 1 and and not as week 0.
I am working with pyspark and koalas (no pandas allowed).
Here is an example:
As you can see, the first column is Date, the second one is week, the third is month and last is year.