@@ -475,81 +475,6 @@ class ChainedAssignmentError(Warning):
475
475
"""
476
476
477
477
478
- _chained_assignment_msg = (
479
- "A value is trying to be set on a copy of a DataFrame or Series "
480
- "through chained assignment.\n "
481
- "When using the Copy-on-Write mode, such chained assignment never works "
482
- "to update the original DataFrame or Series, because the intermediate "
483
- "object on which we are setting values always behaves as a copy.\n \n "
484
- "Try using '.loc[row_indexer, col_indexer] = value' instead, to perform "
485
- "the assignment in a single step.\n \n "
486
- "See the caveats in the documentation: "
487
- "https://pandas.pydata.org/pandas-docs/stable/user_guide/"
488
- "indexing.html#returning-a-view-versus-a-copy"
489
- )
490
-
491
-
492
- _chained_assignment_method_msg = (
493
- "A value is trying to be set on a copy of a DataFrame or Series "
494
- "through chained assignment using an inplace method.\n "
495
- "When using the Copy-on-Write mode, such inplace method never works "
496
- "to update the original DataFrame or Series, because the intermediate "
497
- "object on which we are setting values always behaves as a copy.\n \n "
498
- "For example, when doing 'df[col].method(value, inplace=True)', try "
499
- "using 'df.method({col: value}, inplace=True)' instead, to perform "
500
- "the operation inplace on the original object.\n \n "
501
- )
502
-
503
-
504
- _chained_assignment_warning_msg = (
505
- "ChainedAssignmentError: behaviour will change in pandas 3.0!\n "
506
- "You are setting values through chained assignment. Currently this works "
507
- "in certain cases, but when using Copy-on-Write (which will become the "
508
- "default behaviour in pandas 3.0) this will never work to update the "
509
- "original DataFrame or Series, because the intermediate object on which "
510
- "we are setting values will behave as a copy.\n "
511
- "A typical example is when you are setting values in a column of a "
512
- "DataFrame, like:\n \n "
513
- 'df["col"][row_indexer] = value\n \n '
514
- 'Use `df.loc[row_indexer, "col"] = values` instead, to perform the '
515
- "assignment in a single step and ensure this keeps updating the original `df`.\n \n "
516
- "See the caveats in the documentation: "
517
- "https://pandas.pydata.org/pandas-docs/stable/user_guide/"
518
- "indexing.html#returning-a-view-versus-a-copy\n "
519
- )
520
-
521
-
522
- _chained_assignment_warning_method_msg = (
523
- "A value is trying to be set on a copy of a DataFrame or Series "
524
- "through chained assignment using an inplace method.\n "
525
- "The behavior will change in pandas 3.0. This inplace method will "
526
- "never work because the intermediate object on which we are setting "
527
- "values always behaves as a copy.\n \n "
528
- "For example, when doing 'df[col].method(value, inplace=True)', try "
529
- "using 'df.method({col: value}, inplace=True)' or "
530
- "df[col] = df[col].method(value) instead, to perform "
531
- "the operation inplace on the original object.\n \n "
532
- )
533
-
534
-
535
- def _check_cacher (obj ) -> bool :
536
- # This is a mess, selection paths that return a view set the _cacher attribute
537
- # on the Series; most of them also set _item_cache which adds 1 to our relevant
538
- # reference count, but iloc does not, so we have to check if we are actually
539
- # in the item cache
540
- if hasattr (obj , "_cacher" ):
541
- parent = obj ._cacher [1 ]()
542
- # parent could be dead
543
- if parent is None :
544
- return False
545
- if hasattr (parent , "_item_cache" ):
546
- if obj ._cacher [0 ] in parent ._item_cache :
547
- # Check if we are actually the item from item_cache, iloc creates a
548
- # new object
549
- return obj is parent ._item_cache [obj ._cacher [0 ]]
550
- return False
551
-
552
-
553
478
class NumExprClobberingError (NameError ):
554
479
"""
555
480
Exception raised when trying to use a built-in numexpr name as a variable name.
@@ -831,6 +756,7 @@ class InvalidComparison(Exception):
831
756
"AbstractMethodError" ,
832
757
"AttributeConflictWarning" ,
833
758
"CategoricalConversionWarning" ,
759
+ "ChainedAssignmentError" ,
834
760
"ClosedFileError" ,
835
761
"CSSWarning" ,
836
762
"DatabaseError" ,
0 commit comments