I have this dataframe with daily timeseries
Date ID Country Type Value
2018-01-21 340 ... -1.130000
...................................................
2020-12-22 340 ... -1.550000
2020-12-23 340 ... -1.430000
2020-12-24 340 ... -0.800000
2020-12-25 340 ... 0.000000
I wish to convert it like this
Date 2018 2019 2020
01-21 -1.13 23.21 1.22
01-22 2 3 1.5
...................................
12-22 . -1.55
12-23 -1.43
is there a direct way or I have to first have 2 separate columns: year and month+ day before df.unstack()?
actually the ts are from different countries and categories and I need to group by these 2 criteria, is it feasible to keep all in one df and use hierarchical index or I have to split the df and save them to a dictionary of dfs? (one country and category per df in the dict)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…