Skip to content

Instantly share code, notes, and snippets.

@glemaitre
Created November 2, 2018 11:28
Show Gist options
  • Save glemaitre/98394fa7ec65439ca961fc0384f07aaa to your computer and use it in GitHub Desktop.
Save glemaitre/98394fa7ec65439ca961fc0384f07aaa to your computer and use it in GitHub Desktop.
In [16]: df = pd.DataFrame({'A': [1, 2, 1, 2, 1, 2, 3, 3]})
In [17]: df2 = df[df['A'].isin([1, 2])]
In [18]: df2.loc[df2['A'] == 1, 'A'] = 4
/home/glemaitre/miniconda3/lib/python3.7/site-packages/pandas/core/indexing.py:189: 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)
/home/glemaitre/miniconda3/bin/ipython: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
#!/home/glemaitre/miniconda3/bin/python
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment