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] = valuedf.loc[df.index[0], "load"] = valueWhat the rule reports
Section titled “What the rule reports”The rule reports df["a"].values[0] = 9, which raises ValueError, because the array is read-only under copy-on-write.
How to fix it
Section titled “How to fix it”xpd has no automatic fix, so make the change by hand.
Message
Section titled “Message”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.