We are making a formula in python however, run against the setting with copy warning.
We have tried different .copy() and .loc options but the warning always appears again when we completely re-run the code.
df_no_missing.loc[:,'Turnover'] = (df_no_missing['Quantity'] * df_no_missing['PricePerPiece'])
df_no_missing.head()
We expect the column with the turnover without a warning. We do get the desired output however we would like to get the output without the following warning:
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: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy self.obj[key] = _infer_fill_value(value) /Users/noortjetaal/anaconda3/lib/python3.7/site-packages/pandas/core/indexing.py:543: 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: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy self.obj[item] = s