0

I am trying to multiple columns in a df called mod.result by a value mod.adj_ratio using the following:

 for col in PNL_COLS[:3]:
            mod.result[col]*=mod.adj_ratio

I am getting a

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

I have read the on line post I am assuming its because I am chaining slices together. As a result I have tried:

 for col in PNL_COLS[:3]:
            mod.result.loc[[:,col]]*=mod.adj_ratio

and also tried:

    for col in PNL_COLS[:3]:
             df1=mod.is_pnl[col]
             df2=df1*mod.adj_ratio
             mod.is_pnl[col]=df2

without success. What can I try next?

halfer
  • 19,824
  • 17
  • 99
  • 186
Stacey
  • 4,825
  • 17
  • 58
  • 99

0 Answers0