|
30 | 30 | from pandas._config import (
|
31 | 31 | config,
|
32 | 32 | using_copy_on_write,
|
33 |
| - warn_copy_on_write, |
34 | 33 | )
|
35 | 34 |
|
36 | 35 | from pandas._libs import lib
|
|
105 | 104 | from pandas.errors.cow import (
|
106 | 105 | _chained_assignment_method_msg,
|
107 | 106 | _chained_assignment_warning_method_msg,
|
108 |
| - _check_cacher, |
109 | 107 | )
|
110 | 108 | from pandas.util._decorators import (
|
111 | 109 | deprecate_nonkeyword_arguments,
|
@@ -4407,7 +4405,7 @@ def _check_setitem_copy(self, t: str = "setting", force: bool_t = False) -> None
|
4407 | 4405 | df.iloc[0:5]['group'] = 'a'
|
4408 | 4406 |
|
4409 | 4407 | """
|
4410 |
| - if using_copy_on_write() or warn_copy_on_write(): |
| 4408 | + if using_copy_on_write(): |
4411 | 4409 | return
|
4412 | 4410 |
|
4413 | 4411 | # return early if the check is not needed
|
@@ -7256,22 +7254,6 @@ def fillna(
|
7256 | 7254 | ChainedAssignmentError,
|
7257 | 7255 | stacklevel=2,
|
7258 | 7256 | )
|
7259 |
| - elif ( |
7260 |
| - not PYPY |
7261 |
| - and not using_copy_on_write() |
7262 |
| - and self._is_view_after_cow_rules() |
7263 |
| - ): |
7264 |
| - ctr = sys.getrefcount(self) |
7265 |
| - ref_count = REF_COUNT |
7266 |
| - if isinstance(self, ABCSeries) and _check_cacher(self): |
7267 |
| - # see https://github.com/pandas-dev/pandas/pull/56060#discussion_r1399245221 |
7268 |
| - ref_count += 1 |
7269 |
| - if ctr <= ref_count: |
7270 |
| - warnings.warn( |
7271 |
| - _chained_assignment_warning_method_msg, |
7272 |
| - FutureWarning, |
7273 |
| - stacklevel=2, |
7274 |
| - ) |
7275 | 7257 |
|
7276 | 7258 | value, method = validate_fillna_kwargs(value, method)
|
7277 | 7259 | if method is not None:
|
@@ -7559,22 +7541,6 @@ def ffill(
|
7559 | 7541 | ChainedAssignmentError,
|
7560 | 7542 | stacklevel=2,
|
7561 | 7543 | )
|
7562 |
| - elif ( |
7563 |
| - not PYPY |
7564 |
| - and not using_copy_on_write() |
7565 |
| - and self._is_view_after_cow_rules() |
7566 |
| - ): |
7567 |
| - ctr = sys.getrefcount(self) |
7568 |
| - ref_count = REF_COUNT |
7569 |
| - if isinstance(self, ABCSeries) and _check_cacher(self): |
7570 |
| - # see https://github.com/pandas-dev/pandas/pull/56060#discussion_r1399245221 |
7571 |
| - ref_count += 1 |
7572 |
| - if ctr <= ref_count: |
7573 |
| - warnings.warn( |
7574 |
| - _chained_assignment_warning_method_msg, |
7575 |
| - FutureWarning, |
7576 |
| - stacklevel=2, |
7577 |
| - ) |
7578 | 7544 |
|
7579 | 7545 | return self._pad_or_backfill(
|
7580 | 7546 | "ffill",
|
@@ -7763,22 +7729,6 @@ def bfill(
|
7763 | 7729 | ChainedAssignmentError,
|
7764 | 7730 | stacklevel=2,
|
7765 | 7731 | )
|
7766 |
| - elif ( |
7767 |
| - not PYPY |
7768 |
| - and not using_copy_on_write() |
7769 |
| - and self._is_view_after_cow_rules() |
7770 |
| - ): |
7771 |
| - ctr = sys.getrefcount(self) |
7772 |
| - ref_count = REF_COUNT |
7773 |
| - if isinstance(self, ABCSeries) and _check_cacher(self): |
7774 |
| - # see https://github.com/pandas-dev/pandas/pull/56060#discussion_r1399245221 |
7775 |
| - ref_count += 1 |
7776 |
| - if ctr <= ref_count: |
7777 |
| - warnings.warn( |
7778 |
| - _chained_assignment_warning_method_msg, |
7779 |
| - FutureWarning, |
7780 |
| - stacklevel=2, |
7781 |
| - ) |
7782 | 7732 |
|
7783 | 7733 | return self._pad_or_backfill(
|
7784 | 7734 | "bfill",
|
@@ -7934,26 +7884,6 @@ def replace(
|
7934 | 7884 | ChainedAssignmentError,
|
7935 | 7885 | stacklevel=2,
|
7936 | 7886 | )
|
7937 |
| - elif ( |
7938 |
| - not PYPY |
7939 |
| - and not using_copy_on_write() |
7940 |
| - and self._is_view_after_cow_rules() |
7941 |
| - ): |
7942 |
| - ctr = sys.getrefcount(self) |
7943 |
| - ref_count = REF_COUNT |
7944 |
| - if isinstance(self, ABCSeries) and _check_cacher(self): |
7945 |
| - # in non-CoW mode, chained Series access will populate the |
7946 |
| - # `_item_cache` which results in an increased ref count not below |
7947 |
| - # the threshold, while we still need to warn. We detect this case |
7948 |
| - # of a Series derived from a DataFrame through the presence of |
7949 |
| - # checking the `_cacher` |
7950 |
| - ref_count += 1 |
7951 |
| - if ctr <= ref_count: |
7952 |
| - warnings.warn( |
7953 |
| - _chained_assignment_warning_method_msg, |
7954 |
| - FutureWarning, |
7955 |
| - stacklevel=2, |
7956 |
| - ) |
7957 | 7887 |
|
7958 | 7888 | if not is_bool(regex) and to_replace is not None:
|
7959 | 7889 | raise ValueError("'to_replace' must be 'None' if 'regex' is not a bool")
|
@@ -8384,22 +8314,6 @@ def interpolate(
|
8384 | 8314 | ChainedAssignmentError,
|
8385 | 8315 | stacklevel=2,
|
8386 | 8316 | )
|
8387 |
| - elif ( |
8388 |
| - not PYPY |
8389 |
| - and not using_copy_on_write() |
8390 |
| - and self._is_view_after_cow_rules() |
8391 |
| - ): |
8392 |
| - ctr = sys.getrefcount(self) |
8393 |
| - ref_count = REF_COUNT |
8394 |
| - if isinstance(self, ABCSeries) and _check_cacher(self): |
8395 |
| - # see https://github.com/pandas-dev/pandas/pull/56060#discussion_r1399245221 |
8396 |
| - ref_count += 1 |
8397 |
| - if ctr <= ref_count: |
8398 |
| - warnings.warn( |
8399 |
| - _chained_assignment_warning_method_msg, |
8400 |
| - FutureWarning, |
8401 |
| - stacklevel=2, |
8402 |
| - ) |
8403 | 8317 |
|
8404 | 8318 | axis = self._get_axis_number(axis)
|
8405 | 8319 |
|
@@ -10569,7 +10483,6 @@ def _where(
|
10569 | 10483 | inplace: bool_t = False,
|
10570 | 10484 | axis: Axis | None = None,
|
10571 | 10485 | level=None,
|
10572 |
| - warn: bool_t = True, |
10573 | 10486 | ):
|
10574 | 10487 | """
|
10575 | 10488 | Equivalent to public method `where`, except that `other` is not
|
@@ -10700,7 +10613,7 @@ def _where(
|
10700 | 10613 | # we may have different type blocks come out of putmask, so
|
10701 | 10614 | # reconstruct the block manager
|
10702 | 10615 |
|
10703 |
| - new_data = self._mgr.putmask(mask=cond, new=other, align=align, warn=warn) |
| 10616 | + new_data = self._mgr.putmask(mask=cond, new=other, align=align) |
10704 | 10617 | result = self._constructor_from_mgr(new_data, axes=new_data.axes)
|
10705 | 10618 | return self._update_inplace(result)
|
10706 | 10619 |
|
@@ -12566,29 +12479,8 @@ def _inplace_method(self, other, op) -> Self:
|
12566 | 12479 | """
|
12567 | 12480 | Wrap arithmetic method to operate inplace.
|
12568 | 12481 | """
|
12569 |
| - warn = True |
12570 |
| - if not PYPY and warn_copy_on_write(): |
12571 |
| - if sys.getrefcount(self) <= REF_COUNT + 2: |
12572 |
| - # we are probably in an inplace setitem context (e.g. df['a'] += 1) |
12573 |
| - warn = False |
12574 |
| - |
12575 | 12482 | result = op(self, other)
|
12576 | 12483 |
|
12577 |
| - if ( |
12578 |
| - self.ndim == 1 |
12579 |
| - and result._indexed_same(self) |
12580 |
| - and result.dtype == self.dtype |
12581 |
| - and not using_copy_on_write() |
12582 |
| - and not (warn_copy_on_write() and not warn) |
12583 |
| - ): |
12584 |
| - # GH#36498 this inplace op can _actually_ be inplace. |
12585 |
| - # Item "BlockManager" of "Union[BlockManager, SingleBlockManager]" has |
12586 |
| - # no attribute "setitem_inplace" |
12587 |
| - self._mgr.setitem_inplace( # type: ignore[union-attr] |
12588 |
| - slice(None), result._values, warn=warn |
12589 |
| - ) |
12590 |
| - return self |
12591 |
| - |
12592 | 12484 | # Delete cacher
|
12593 | 12485 | self._reset_cacher()
|
12594 | 12486 |
|
|
0 commit comments