Input File
Market | State | Viewership | Spend |
---|---|---|---|
North | CNN | 35128 | 907592 |
North | FOX | 53343 | 423132 |
South | CNN | 65656 | 553434 |
South | FOX | 75757 | 664646 |
East | CNN | 43443 | 123233 |
East. | FOX | 34345 | 987876 |
West | CNN | 65644 | 343453 |
West | FOX | 67462 | 664534 |
How do I transform this table into the one below using Python? I am trying to ingest the data from csv to flip the data into this format. Can I use pivot or how exactly can this be done? The image at the top is the raw data and the one at the bottom is the format in which I want to view the results…
Expected Output:
KPI | Market | State | value |
---|---|---|---|
Viewership | North | CNN | 35128 |
Spend | North | CNN | 907592 |
Viewership | North | FOX | 53343 |
Spend | North | FOX | 423132 |
Viewership | South | CNN | 65656 |
Spend | South | CNN | 553434 |
Viewership | South | FOX | 75757 |
Spend | South | FOX | 664646 |
Viewership | East | CNN | 43443 |
Spend | East | CNN | 123233 |
Viewership | East | FOX | 34345 |
Spend | East | FOX | 987876 |
Viewership | West | CNN | 65644 |
Spend | West | CNN | 343453 |
Viewership | West | FOX | 343453 |
Spend | West | FOX | 664534 |
2