Skip to content

Commit d4ae649

Browse files
DOC: rephrase CoW ChainedAssignmentError message now CoW is always enabled (#61970)
1 parent d79cc2f commit d4ae649

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

pandas/errors/cow.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
11
_chained_assignment_msg = (
22
"A value is trying to be set on a copy of a DataFrame or Series "
33
"through chained assignment.\n"
4-
"When using the Copy-on-Write mode, such chained assignment never works "
5-
"to update the original DataFrame or Series, because the intermediate "
6-
"object on which we are setting values always behaves as a copy.\n\n"
4+
"Such chained assignment never works to update the original DataFrame or "
5+
"Series, because the intermediate object on which we are setting values "
6+
"always behaves as a copy (due to Copy-on-Write).\n\n"
77
"Try using '.loc[row_indexer, col_indexer] = value' instead, to perform "
88
"the assignment in a single step.\n\n"
9-
"See the caveats in the documentation: "
9+
"See the documentation for a more detailed explanation: "
1010
"https://pandas.pydata.org/pandas-docs/stable/user_guide/"
11-
"copy_on_write.html"
11+
"copy_on_write.html#chained-assignment"
1212
)
1313

1414

1515
_chained_assignment_method_msg = (
1616
"A value is trying to be set on a copy of a DataFrame or Series "
1717
"through chained assignment using an inplace method.\n"
18-
"When using the Copy-on-Write mode, such inplace method never works "
19-
"to update the original DataFrame or Series, because the intermediate "
20-
"object on which we are setting values always behaves as a copy.\n\n"
18+
"Such inplace method never works to update the original DataFrame or Series, "
19+
"because the intermediate object on which we are setting values always "
20+
"behaves as a copy (due to Copy-on-Write).\n\n"
2121
"For example, when doing 'df[col].method(value, inplace=True)', try "
2222
"using 'df.method({col: value}, inplace=True)' instead, to perform "
23-
"the operation inplace on the original object.\n\n"
23+
"the operation inplace on the original object, or try to avoid an inplace "
24+
"operation using 'df[col] = df[col].method(value)'.\n\n"
25+
"See the documentation for a more detailed explanation: "
26+
"https://pandas.pydata.org/pandas-docs/stable/user_guide/"
27+
"copy_on_write.html"
2428
)

0 commit comments

Comments
 (0)