Skip to content

DOC: rephrase CoW ChainedAssignmentError message now CoW is always enabled #61970

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 30, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions pandas/errors/cow.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
_chained_assignment_msg = (
"A value is trying to be set on a copy of a DataFrame or Series "
"through chained assignment.\n"
"When using the Copy-on-Write mode, such chained assignment never works "
"to update the original DataFrame or Series, because the intermediate "
"object on which we are setting values always behaves as a copy.\n\n"
"Such chained assignment never works to update the original DataFrame or "
"Series, because the intermediate object on which we are setting values "
"always behaves as a copy (due to Copy-on-Write).\n\n"
"Try using '.loc[row_indexer, col_indexer] = value' instead, to perform "
"the assignment in a single step.\n\n"
"See the caveats in the documentation: "
"See the documentation for a more detailed explanation: "
"https://pandas.pydata.org/pandas-docs/stable/user_guide/"
"copy_on_write.html"
"copy_on_write.html#chained-assignment"
)


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