I have a dataset with a few columns including indicator code & indicator Name. I want to change the indicator name based on the indicator code. I have a dict where the indicator code is the key, and the name is the value. When I run npwhere to place the updated information, i get a type error. Any ideas how to fix this?
tempdict = {'EN.ATM.GHGT.KT.CE': 'Total', 'EN.ATM.CO2E.KT': 'CO2', 'EN.ATM.METH.KT.CE': 'CH4', 'EN.ATM.NOXE.KT.CE': 'N2O', 'EN.ATM.GHGO.KT.CE': 'Other', 'EN.ATM.PM25.MC.M3': 'PM2.5', 'EN.ATM.PM25.MC.ZS': 'PM2.5_WHO'} Emissions_C_df['Indicator Name'] = np.where((Emissions_C_df['Indicator Code'].isin(tempdict.keys()) == True, tempdict.get(Emissions_C_df['Indicator Code']), Emissions_C_df['Indicator Code']))
https://stackoverflow.com/questions/65768687/series-objects-are-mutable-thus-they-cannot-be-hashed-when-using-npwhere-and January 18, 2021 at 12:04PM
没有评论:
发表评论