0

I am getting warnings for str.replace and str.split for the below codes

df['Amount'] = df['Amount'].str.replace(')', '')   
df[['Inside','Outside']] = df.Amount.str.split(",",expand=True) 

Below is the Warning

dynamic_module:222: 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


C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\frame.py:3391: 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[k1] = value[k2]

df['Amount'].loc usage doesn't help, may be not used properly, what could be the correct way?

hanzgs
  • 1,498
  • 17
  • 44
  • Problem is obviously in code before you posted, check [this](https://stackoverflow.com/questions/20625582/how-to-deal-with-settingwithcopywarning-in-pandas) - I think it is dupe – jezrael Aug 14 '19 at 06:46
  • Got the Answer from https://stackoverflow.com/questions/38147027/action-with-pandas-settingwithcopywarning/38147527 @ysearka In the First place df = df1.copy() to be done, Thanks – hanzgs Aug 15 '19 at 01:38

0 Answers0