0

I have a dataframe with two columns. The first column is a country name, the second column is the ID of an occurrence.

Country      Occurrence ID
   A              One
   B              Two
   C              One
   A             Three
   D              One
   D              One
  ...             ...

I want to pivot my dataframe such that I have an aggregate of all the occurrence ID's that happened in each country

Country        Occurrence One         Occurrence Two      Occurrence Three
  A                 5                      9                    13
  B                 6                      10                   15
  C                 7                      11                   19

I'm unfamiliar with how pivot, pivot_table or unstack work and haven't been able to work this one out using google. Any help would be really appreciated

Thanks

Mistakamikaze
  • 446
  • 3
  • 19

0 Answers0