How to update/create column in pandas based on values in a list

You need numpy.where with condition with isin:

x['Continent'] = np.where(x['Country'].isin(europe), 'Europe', 'Not Europe')
print (x)
     Name Country  Income   Continent
0   Steve     USA   40000  Not Europe
1    Matt      UK   40000      Europe
2    John     USA   40000  Not Europe
3  Martin  France   40000      Europe

Leave a Comment