0

Here's my df:

data = {'Country':['France', 'Spain', 'Japan', 'South Korea', 'South Africa', 'Egypt'],
   'Region':['', 'Europe', '', 'Asia', '', 'Africa']}
df = pd.DataFrame(data)

I also have the following dictionary:

my_dict = {
'France':'Europe',
'Spain':'Europe',
'Japan':'Asia',
'South Korea':'Asia',
'South Africa':'Africa',
'Egypt':'Africa'}

My goal is to fill in the blanks in the 'Region' column in the dataframe, using the pairs contained in the dictionary.

I've tried multiple things, the latest one being:

for k in my_dict.keys():
df.replace({'Country':{k:my_dict[k]}}, inplace=True)

but nothing gets replaced. What am I doing wrong? Thank you!

0 Answers0