1

I have this dataframe

Year Country Gold Silver Bronze
1896 Afghanistan 5 4 3
1896 Algeria 1 2 3

And I want to unstack it like this:

Year Country medal no of medals
1896 Afghanistan Gold 5
1896 Afghanistan Silver 4
1896 Afghanistan Bronze 3
1896 Algeria Gold 1
1896 Algeria Silver 2
1896 Algeria Bronze 3

The idea that I have in mind is iterate over each year and create a new dataframe but I'm very stuck with that.

mosc9575
  • 5,618
  • 2
  • 9
  • 32

0 Answers0