0

I seem to run into this warning quite often and not sure how to avoid it.

Whenever I simply want to create a new column in a dataframe in Pandas and apply a single value to it, or overwrite all values in a column with something like this:

df['flag'] = 'core'

I run into the following warning:

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

As I am not trying to set a subset or specific rows, I cannot see how to adapt to use .loc instead?

NickP
  • 1,206
  • 1
  • 18
  • 40

0 Answers0