I am trying to map a dictionary to a dataframe. I dug through some code and pieced together what I thought would work, but the code isn't running. Can anyone help with getting this to map?
Top15 is an existing dataframe with Country as the Index.
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'}
Top15['Continent'] = Top15['Country'].map(ContinentDict)