I would like to reshape data from long to wide. Especially columns [SAP Version, FY, Period, value]
What I have tried so far:
df.reset_index() df = df.set_index(['Project No_left','Name','SBU Name','Reporting Level 1','Reporting Level 2','Reporting Level 3']) Current DF:
Project No_left Name| Reporting Level 1| Reporting Level 2| Reporting Level 3| SAP Version| FY| Period| value| 0-01214 Project A| IP| NI| FS| 0| 2020| Oct| 1939.92| 0-01214 Project A| IP| NI| FS| 63| 2020| Oct| 1939.92| 0-01214 Project A| IP| NI| FS| 64| 2020| Oct| 1939.92| 0-01214 Project A| IP| NI| FS| 65| 2020| Oct| 1939.92| 0-01214 Project A| IP| NI| FS| 0| 2020| Nov| 9052.96| 0-01214 Project A| IP| NI| FS| 63| 2020| Nov| 9052.96| 0-01032 Project B| IP| AR| PO| 0| 2021| Jul| 27842.5| 0-01032 Project B| IP| AR| PO| 0| 2021| Jul| 30000| 0-01032 Project B| IP| AR| PO| 63| 2021| Jul| 672500| 0-01032 Project B| IP| AR| PO| 64| 2021| Jul| 27842.5| 0-01032 Project B| IP| AR| PO| 64| 2021| Jul| 50000| 0-01032 Project B| IP| AR| PO| 0| 2021| Aug| 27842.5| 0-01032 Project B| IP| AR| PO| 0| 2021| Aug| 50000| 0-01032 Project B| IP| AR| PO| 63| 2021| Aug| 297500| 0-01032 Project B| IP| AR| PO| 64| 2021| Aug| 27842.5| Expected DF:
+------------------+------------+--------------------+--------------------+--------------------+-------+-------+-------+-------+-------+-------+-------+-------+ | Project No_left| | Name| | Reporting Level 1 | Reporting Level 2| | Reporting Level 3| | 0| | 63| | 64| | 65| | 0| | 63| | 64| | 65| | +------------------+------------+--------------------+--------------------+--------------------+-------+-------+-------+-------+-------+-------+-------+-------+ | Project No_left| | Name| | Reporting Level 1 | Reporting Level 2| | Reporting Level 3| | 2020| | 2020| | 2020| | 2020| | 2021| | 2021| | 2021| | 2021| | | Project No_left| | Name| | Reporting Level 1| | Reporting Level 2| | Reporting Level 3| | Jul| | Aug| | Oct| | Nov| | Jul| | Aug| | Oct| | Nov| | | 0-01214| | Project A| | IP| | NI| | FS| | | | | | | | | | | 0-01032| | Project B| | IP| | AR| | PO| | | | | | | | | | +------------------+------------+--------------------+--------------------+--------------------+-------+-------+-------+-------+-------+-------+-------+-------+ can someone also tell me how to create a table to paste, i have tried this https://senseful.github.io/text-table/ but doesn't work properly :(
Pasting a picture as well to explain the outcome better. Thanksenter image description here