exception pandas.errors.SettingWithCopyError[source]

Exception is raised when trying to set on a copied slice from a dataframe and the mode.chained_assignment is set to ‘raise.’ This can happen unintentionally when chained indexing.

For more information on eveluation order, see the user guide.

For more information on view vs. copy, see the user guide.


>>> pd.options.mode.chained_assignment = 'raise'
>>> df = pd.DataFrame({'A': [1, 1, 1, 2, 2]}, columns=['A'])
>>> df.loc[0:3]['A'] = 'a' 
... # SettingWithCopyError: A value is trying to be set on a copy of a...