I have a dataframe,
Year Start End Name Price
0 nan 0101 0331 Squirtle 876
1 2021 0101 1231 Squirtle 200
2 nan 0101 0331 Wartortle 1000
3 2021 0101 1231 Wartortle 1200
4 nan 0101 0331 Blastoise 3100
5 2021 0101 1231 Blastoise 4200
6 2022 0101 1231 Blastoise 10000
I want to reshape it like this,
Name Squirtle Wartortle Blastoise
Year Start End
nan 0101 0331 876 1000 3100
2021 0101 1231 200 1200 4200
2022 0101 1231 10000
I tried,
df.pivot(index=['Year', 'Start', 'End'], columns='Name', values='Price'). But didn't get any luck.
Any help would be appreciated!