0

So I am using a custom function convert_to_decimals and I want to apply them to a column called 'Cost'. I've tried several way but I keep getting the same error:

/Users/gabrielalcivar/opt/anaconda3/envs/dev/lib/python3.7/site-packages/pandas/core/indexing.py:723: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
  iloc._setitem_with_indexer(indexer, value, self.name)

I've tried the following:

curr_pos.loc[:,['Cost']]=curr_pos.loc[:,['Cost']].apply(convert_to_decimals).copy(deep=False)

curr_pos.loc[:,['Cost']]=curr_pos.loc[:,['Cost']].apply(convert_to_decimals)

curr_pos['Cost']=curr_pos['Cost'].apply(convert_to_decimals).copy()

curr_pos.loc[:,['Cost']]=curr_pos['Cost'].apply(convert_to_decimals).copy()

curr_pos.loc[:,['Cost']]=curr_pos['Cost'].apply(convert_to_decimals)

curr_pos.loc[:,['Cost']].apply(convert_to_decimals)

Nothing has worked.

galgo
  • 734
  • 3
  • 17
  • 45

0 Answers0