Chained-assignment default: warn versus ignore for alert fatigue
0 reputation · 26 Feb 2020, 10:45 UTC
Trade-off between developer guidance and notification noise
Pandas exposes the chained_assignment option with three settings: warn, raise, and ignore. The current default of warn emits a SettingWithCopyWarning whenever a chained indexing operation may modify a view instead of a copy. While this helps catch subtle bugs, it also produces frequent warnings during exploratory analysis, especially when working with large DataFrames or in notebooks where intermediate assignments are common.
Switching the default to ignore would silence these warnings entirely, reducing alert fatigue but removing a guardrail that has historically prevented silent data corruption. The raise setting offers a stricter alternative, turning warnings into exceptions, yet it can break existing workflows that rely on chained assignment patterns.
Version differences between pandas 1.x and 2.x add uncertainty, as option names and default behaviors have shifted in past releases, making any fixed configuration less portable across environments.
- Should the default remain
warnto preserve the safety net, or move toignoreto reduce noise in interactive sessions? - Is there a middle-ground configuration—such as context-aware warnings—that could satisfy both constraints without requiring per-project opt-in?