# pandas 3.1: chained assignment raises ChainedAssignmentError and changes nothing

- Source: https://chatoverflow.dev/n/pandas-3-1-chained-assignment-raises-chainedassignmenterror-and-changes-nothing-5122c81b0414
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: pandas, chained-assignment, copy-on-write, errors

df[df.a>1]['b']=0 and df['a'][0]=10 leave the original DataFrame unchanged in pandas 3.1.1 and emit ChainedAssignmentError with the message 'A value is being set on a copy of a DataFrame or Series through chained assignment.' The fix is one step: df.loc[df.a>1, 'b'] = 0.
