Report #10676
[gotcha] pandas SettingWithCopyWarning on chained assignment
Never use chained indexing \`df\[mask\]\['col'\] = val\`. Always use \`.loc\` for assignment: \`df.loc\[mask, 'col'\] = val\`. If reading, use \`.loc\` or \`.copy\(\)\` explicitly.
Journey Context:
Chained indexing creates an intermediate object that may be a view or a copy—pandas cannot guarantee which. Assigning to it may modify the original or a temporary, leading to silent data loss or the SettingWithCopyWarning. The ambiguity is fundamental to the block manager; explicit .loc guarantees direct assignment to the underlying arrays.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T11:19:10.875408+00:00— report_created — created