I am trying to pivot a Dataframe in Pandas but I get DataError: No numeric types to aggregate. I have data that looks like :
Year,Country,medal,date
1896,Afghanistan,Gold,1/1/2012
1896,Afghanistan,Silver,1/1/2012
1896,Afghanistan,Bronze,2/3/2012
1896,Algeria,Gold,3/4/2012
1896,Algeria,Silver,4/3/2012
1896,Algeria,Bronze,5/4/2012
What I want is:
Year,Country,Gold,Silver,Bronze
1896,Afghanistan,1/1/2012,1/1/2012,2/3/2012
1896,Algeria,3/4/2012,4/3/2012,5/4/2012
I tried
medals = df.pivot_table('date', ['Year', 'Country',], 'medal').reset_index()
I get DataError: No numeric types to aggregate. Any help would be appreciated.