write a dataframe using a column that contains a cycle (number of the weekin every year) in python
I want to write a dataframe with a column of the number of week and make it as a row that contains 53 columns (I mean weeks). I really need your help.
NOTE THAT: each year has 53 week, and the column week number its like a cycle
The data that I have:
Date PS Week_Number
0 1980-12-29 43.81 1
1 1981-01-05 81.56 2
2 1981-01-12 69.58 3
3 1981-01-19 92.26 4
4 1981-01-26 108.64 5
... ... ... ...
53 1981-12-07 106.91 53
54 1982-12-14 100.75 1
55 1982-12-21 107.69 2
... ... ... ...
2084 2020-12-07 106.91 50
2085 2020-12-14 100.75 51
The format that I want:
year\week number 1 2 3 4 5 .... 53
1980 43.81 15 49 .. .. ..
1981 81.56 26 70
... ... ... ...
2020 107.69 49 ..
Thank you
I already used this code but it shows this error:
df.assign(Year=df[Date].dt.year).pivot(Year,Week_Number,PS)
it shows me the error: (Index contains duplicate entries, cannot reshape)
Category Data Science