- API reference
- Testing
- pandas.error...
pandas.errors.ChainedAssignmentError#
- exceptionpandas.errors.ChainedAssignmentError[source]#
Warning raised when trying to set using chained assignment.
When the
mode.copy_on_writeoption is enabled, chained assignment cannever work. In such a situation, we are always setting into a temporaryobject that is the result of an indexing operation (getitem), which underCopy-on-Write always behaves as a copy. Thus, assigning through a chaincan never update the original Series or DataFrame.For more information on view vs. copy,seethe user guide.
Examples
>>>pd.options.mode.copy_on_write=True>>>df=pd.DataFrame({'A':[1,1,1,2,2]},columns=['A'])>>>df["A"][0:3]=10...# ChainedAssignmentError: ...>>>pd.options.mode.copy_on_write=False
On this page