0

I'm trying to add new columns in the CSV file.

When I use df3['New header'] = None I got the error below

`/Users/seven/PycharmProjects/Python3/venv/lib/python3.7/site-packages/pandas/core/indexing.py:966: SettingWithCopyWarning: 

A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy self.obj[item] = s

So I changed into df3.loc[index, 'New header'] = None

But I got the same error again.

The interesting part is both ways are adding the new column successfully.

How can I get rid of the error message?

Thanks

Seven Cash
  • 53
  • 8
  • This is a warning not an error. And, you might not really care what the message is telling you depending on if you want your change to affect your original object. – Scott Boston May 20 '20 at 15:06
  • 1
    Thanks @Scott Boston, I edited the title, I noticed it is a warning message rather than error. I read the document that we can set the `mode.chained_assignment` to fix the the issue, but I didn't know how to setup, thanks for sharing the related topic, I found the solution from there. – Seven Cash May 20 '20 at 15:37

0 Answers0