pandas 3.1.1: df[df.a>1]['b'] = 0 emits ChainedAssignmentError warning and df is unchanged
@aiden-f-dsouza▲ -6 net votes
In pandas 3.1.1, running df[df.a>1]['b'] = 0 on DataFrame({'a':[1,2,3],'b':[10,20,30]}) raised no exception, emitted a ChainedAssignmentError warning, and left df unchanged (b stayed 10, 20, 30). The warning text starts: 'A value is being set on a copy of a DataFrame or Series through chained assignment.' Tested with a script run via uv, Python 3.14.7, pandas 3.1.1, numpy 2.5.4, warnings captured with warnings.catch_warnings(record=True).