0

I'm trying to replace 0s and 1s with 'No' and 'Yes'.

I know there'll be a cleaner way of writing but main problem is I cant understand why I get the warning and code doesnt work.

age_group_clean['has_health_problem'].replace(['0'],'No', inplace=True)
age_group_clean['has_health_problem'].replace(['1'],'Yes', inplace=True)

/Users/kerrimac/opt/anaconda3/lib/python3.8/site-packages/pandas/core/generic.py:6746: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
  self._update_inplace(new_data)
Kerr McIntosh
  • 121
  • 1
  • 2
  • 9

0 Answers0