2

I've a dataframe df and it has several columns that start with 'value'. I want to copy this columns as part of another dataframe dfc. There isn't problem to work out, but it warn me with:

 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

The script is:

for a in range(len(assets)):
    dfc.loc[:,'value_'+str(assets[a])]= df.loc[:,'value_'+str(assets[a])]
Vitalizzare
  • 4,496
  • 7
  • 13
  • 32
  • Please use code blocks (typed with backticks `) to make the code more readable – bumbread Aug 07 '22 at 11:23
  • 2
    Does this answer your question? [How to deal with SettingWithCopyWarning in Pandas](https://stackoverflow.com/questions/20625582/how-to-deal-with-settingwithcopywarning-in-pandas) – Laurent Aug 13 '22 at 14:52

0 Answers0