Reputation: 71
Let me breakdown what I'm trying to do,
But I keep getting the below error,
SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame
The code I've written to do the above,
filt = app_data['NAME_INCOME_TYPE'] == 'Pensioner'
app_data.loc[filt]['OCCUPATION_TYPE'].fillna('Retiree', inplace = True)
Upvotes: 0
Views: 137
Reputation: 12140
I believe using .loc[filter, column].fillna(...)
like:
filt = app_data['NAME_INCOME_TYPE'] == 'Pensioner'
app_data.loc[filt,'OCCUPATION_TYPE'] = app_data.loc[filt,'OCCUPATION_TYPE'].fillna('Retiree')
should work.
Upvotes: 1