0

I have a boolean mask against a dataframe that works for me:

df.loc[df.loc[:,'Col1'].str.contains('_id'),'Col2']='stringValue'

but get the error

/opt/conda/lib/python3.6/site-packages/pandas/core/indexing.py:141: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self._setitem_with_indexer(indexer, value)
/opt/conda/lib/python3.6/site-packages/ipykernel_launcher.py:1: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  """Entry point for launching an IPython kernel.

I have researched this and can not come up with a way to write it without getting this error any help?

Arpit Solanki
  • 9,567
  • 3
  • 41
  • 57
wrgrnt
  • 1
  • Nothing wrong with the way you wrote it. It's what you did before. df is a slice of another dataframe so all changes to it will trigger this warning. Set `df.is_copy = None` before this assignment and the warning will disappear. – ayhan May 31 '18 at 05:06
  • Yes it did and Thank You – wrgrnt May 31 '18 at 05:34

0 Answers0