Home > Blockchain >  How to fix "ValueError: Series.replace cannot use dict-like to_replace and non-None value "
How to fix "ValueError: Series.replace cannot use dict-like to_replace and non-None value "

Time:10-25

I tried to use this following line of code to replace the retirees' incorrect days values ​​with 9000, but I get the error in the title. This is the line: df.replace(df.loc[(df['days_employed']>100000) & (df['income_type']=='retiree')], 9000)

CodePudding user response:

refer to the LOC documentation, section 'setting values'

the second parameter to the loc is the column to update

# replace the col-to-update, with the column you like to update
df.loc[(df['days_employed']>100000) & (df['income_type']=='retiree'),'col-to-update']= 9000

  • Related