In the adult_quasiIdentifer data frame, there is a column called nativeCountry. I am trying to modify the nativeCountry so that it contains the continent, instead of the country name.
Here is my code:
North_America = ['United-States', 'Cuba', 'Jamaic', 'Mexico', 'Puerto-Rico', 'Honduras','Canada','Haiti', 'Dominican-Republic', 'El-Salvador', 'Guatemala','Nicaragua' ]
South_America = ['Columbia','Ecuador', 'Peru','Trinadad&Tobago']
Asia = ['India', 'Iran','Philippines', 'Cambodia', 'Thailand','Laos', 'Taiwan', 'China', 'Japan', 'Vietnam','Hong']
Europe = ['England','Germany', 'Italy','Poland', 'Portugal', 'France', 'Yugoslavia','Scotland', 'Greece', 'Ireland', 'Hungary','Holand-Netherlands']
contient = {'North_America': North_America,'South_America': South_America, 'Asia': Asia, 'Europe': Europe}
for key, val in contient.items():
adult_quasiIdentifier.loc[adult_quasiIdentifier.nativeCountry.isin(val),"nativeCountry"] = key
adult_quasiIdentifier
The quasiIdentifier data set did not get modified, and I also get the message saying that
I don't know what's wrong with my code. Is there any way I can modify the nativeCountry column? Thanks!