I am working on the Medical Data Visualizer challenge and I am reassigning DataFrame values based on some conditions, like this :
df['cholesterol'].loc[df['cholesterol'] == 1] = 0 #normalizing cholestrol values df['cholesterol'].loc[df['cholesterol'] > 1] = 1 #normalizing cholestrol values
This seems to work, however , I am also working with Jupyter Notebooks and when I load the snipet with this code I get the following warning :
/usr/local/lib/python3.7/dist-packages/pandas/core/indexing.py:670: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame
Now I am wondering if this is the best way to do it (best practice) or there is other way I should reassign those values.
Just looking for the best practice on this subject to not cause future errors.