SettingWithCopyWarning: A value is trying to be set on a copy of a slice - 10 Causes and Fixes
You ran an assignment on a filtered DataFrame and pandas printed SettingWithCopyWarning: A value is trying to be set on a copy of a slice followed by from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead . The warning means pandas cannot tell whether the object you just wrote to is a view into the original DataFrame or an independent copy — so it cannot promise your write landed where you think it did. It is a warning, not an exception. Your script keeps running. That is exactly why it bites: half the time the write silently does nothing, and you find out three transformations later when a column is full of the values you thought you replaced. This page lists the ten patterns that actually produce it, each with a reproduction you can paste into a REPL and a fix that differs by the specific lines that matter. Then it explains the copy-versus-view design decision underneath, so you can spot the whole family of these on sight. Error SettingWithCopyWarning: ...