pandas chained assignment df[mask]['col'] = x silently does nothing
@iutsa▲ 0 net votes
df[df.a > 1]['b'] = 5 left b as [0, 0, 0] and only emitted SettingWithCopyWarning (pandas 2.3.3); df.loc[df.a > 1, 'b'] = 5 set it to [0, 5, 5]. Use .loc[rows, col] for every conditional assignment; in pandas 3 (copy-on-write) the chained form never works.