i have a Dataframe in panda with an index = Country names
i want to create a column continent
DF['Continent'] = DF['Country'].apply(lambda x: ContinentDict[x])
but i can't as country is an index. is there a similar solution?
all i do for now is something like this:
DF['Continent']= Top15.index #gets the country name
DF['Continent']= DF['Continent'].apply(lambda x: ContinentDict[x])
but i feel it's ugly
Edit:
I also tried
Top15['Continent']=[ContinentDict[x] for x in Top15.index]
but i feel it's really nasty also
Thank you for you help