I have a dataset where I would like to pivot the entire dataframe, using certain columns as values.
Data
id date sun moon stars total ppp base final final2
aa Q1 21 5 1 2 8 0 200 41 5
aa Q2 21 4 1 2 7 1 200 50 6
Desired
id date type ppp base final final2
aa Q1 21 sun 0 200 41 5
aa Q1 21 moon 0 200 41 5
aa Q1 21 stars 0 200 41 5
aa Q2 21 sun 1 200 50 6
aa Q2 21 moon 1 200 50 6
aa Q2 21 stars 1 200 50 6
Doing
df.pivot(index='foo', columns='bar', values='baz')
(sample code)
I believe I have to perform something similar to this, but not exactly sure how to arrange this. I am still researching, any suggestion is appreciated.