Skip to content

pandas/write-through-values

Rule write-through-values
Pack pandas
Severity error
Fix none, edit by hand
Library versions every version

Under copy-on-write, the array behind a column is read-only, so writing through .values raises ValueError. Assign with .loc instead.

df["load"].values[0] = value
df.loc[df.index[0], "load"] = value

The rule reports df["a"].values[0] = 9, which raises ValueError, because the array is read-only under copy-on-write.

xpd has no automatic fix, so make the change by hand.

xpd prints this message with the issue. A name that starts with $ stands for code from your file.

The array behind a column is read-only under copy-on-write, so this write raises ValueError. Assign with .loc instead, as in df.loc[df.index[0], "a"] = value.

Browse the other rules of the pandas pack.