0

I have line:

df[["col_1", "col_2"]].replace(np.nan, "value", inplace = True)

And I get warrning: A value is trying to be set on copy of xlice from DataFrame.

could you explain me why I have that message, and how I can fix it? Thank you in advance

Adrien Pacifico
  • 1,649
  • 1
  • 15
  • 33
Abradab3
  • 45
  • 3
  • Does this answer your question? [How to deal with SettingWithCopyWarning in Pandas](https://stackoverflow.com/questions/20625582/how-to-deal-with-settingwithcopywarning-in-pandas) – masoud Aug 22 '22 at 12:04
  • It does not work – Abradab3 Aug 22 '22 at 12:17
  • Try this: `df.loc[:, ["col_1", "col_2"]] = df.loc[:, ["col_1", "col_2"]].replace(np.nan, "value")` – masoud Aug 22 '22 at 12:29

0 Answers0