Skip to content

Commit 89185cd

Browse files
committed
Create baseline commit for warning message
1 parent 4514636 commit 89185cd

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

pandas/errors/__init__.py

+13
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,19 @@ class ChainedAssignmentError(Warning):
503503
)
504504

505505

506+
_chained_assignment_warning_method_msg = (
507+
"A value is trying to be set on a copy of a DataFrame or Series "
508+
"through chained assignment using an inplace method.\n"
509+
"The behavior will change in pandas 3.0. This inplace method will "
510+
"never work because the intermediate object on which we are setting "
511+
"values always behaves as a copy.\n\n"
512+
"For example, when doing 'df[col].method(value, inplace=True)', try "
513+
"using 'df.method({col: value}, inplace=True)' or "
514+
"df[col] = df[col].method(value) instead, to perform "
515+
"the operation inplace on the original object.\n\n"
516+
)
517+
518+
506519
class NumExprClobberingError(NameError):
507520
"""
508521
Exception raised when trying to use a built-in numexpr name as a variable name.

scripts/validate_unwanted_patterns.py

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
"_global_config",
5151
"_chained_assignment_msg",
5252
"_chained_assignment_method_msg",
53+
"_chained_assignment_warning_method_msg",
5354
"_version_meson",
5455
# The numba extensions need this to mock the iloc object
5556
"_iLocIndexer",

0 commit comments

Comments
 (0)