I have a dataframe 'Top15' whose index is country :
Top15.index
Index(['China', 'United States', 'Japan', 'United Kingdom',
'Russian Federation', 'Canada', 'Germany', 'India', 'France',
'South Korea', 'Italy', 'Spain', 'Iran', 'Australia', 'Brazil'],
dtype='object', name='Country')
I have a dictionary which has continent for each country.
ContinentDict = {'China':'Asia',
'United States':'North America',
'Japan':'Asia',
'United Kingdom':'Europe',
'Russian Federation':'Europe',
'Canada':'North America',
'Germany':'Europe',
'India':'Asia',
'France':'Europe',
'South Korea':'Asia',
'Italy':'Europe',
'Spain':'Europe',
'Iran':'Asia',
'Australia':'Australia',
'Brazil':'South America'}
I want to group the countries by continent. I created a column 'Continent'
Top15['Continent']=Top15.index.map(ContinentDict)
After that i tried to group by continent
Top15.groupby('Continent')
I received following output:
<pandas.core.groupby.generic.DataFrameGroupBy object at 0x0000023CBF691AC8>
When i checked the dataframe, it was not grouped. Is it because country is index and not in column? What should i do?