Pandas: SettingWithCopyWarning: [duplicate]

You need add copy:

df = data.loc[data.ID == 79]

to:

df = data.loc[data.ID == 79].copy()

If you modify values in df later you will find that the modifications do not propagate back to the original data (data), and that Pandas does warning.

Leave a Comment