0

I would like to copy 1 column of the Dataframe, but I get always a warning message: "A value is trying to be set on a copy of a slice from a DataFrame." I know it is because of Chained assignment, I only can't find a proper solution:

This is the first method which is not works:

data3['Close2'] = data3['Close']

I tried another methods, just like below, but nothing of them works:

data3['Close2'] = data3['Close'].copy()
data3['Close2']=data3['Close'].values
data3['Close_input'] = data3['Close'].copy(deep=True)
data3['Close_input'] = data3.loc[:, ('Close')] 
data3.Close_input = data3.Close

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

How should I modify my code to avoid warning messages?

Thanks in advance, R

Roland Szarka
  • 77
  • 1
  • 4

0 Answers0