I would like to rearrange cross-section into panel data.
Unfortunately I was not able to rearrange it with the pd.melt
or pd.pivot
formula. I also searched in the stack overflow community for a solution but did not find an answer which matches the problem.
The current data have the following form:
ID FA_17 FA_18 TA_17 TA_18 OR_17 OR_18
-----------------------------------------------------
ID1 590 304 313 682 671 499
ID2 832 344 482 223 580 789
ID3 598 138 125 712 775 761
In the end they should be transformed into the following order:
FA TA OR
ID1 FA_17 TA_17 OR_17
ID1 FA_18 TA_18 OR_18
ID2 FA_17 TA_17 OR_17
ID2 FA_18 TA_18 OR_18
ID3 FA_17 TA_17 OR_17
ID3 FA_18 TA_18 OR_18
Thank you very much in advance!