|
101 | 101 | SettingWithCopyWarning,
|
102 | 102 | _chained_assignment_method_msg,
|
103 | 103 | _chained_assignment_warning_method_msg,
|
| 104 | + _check_cacher, |
104 | 105 | )
|
105 | 106 | from pandas.util._decorators import (
|
106 | 107 | deprecate_nonkeyword_arguments,
|
@@ -7195,7 +7196,7 @@ def fillna(
|
7195 | 7196 | elif not PYPY and not using_copy_on_write():
|
7196 | 7197 | ctr = sys.getrefcount(self)
|
7197 | 7198 | ref_count = REF_COUNT
|
7198 |
| - if isinstance(self, ABCSeries) and hasattr(self, "_cacher"): |
| 7199 | + if isinstance(self, ABCSeries) and _check_cacher(self): |
7199 | 7200 | # see https://github.com/pandas-dev/pandas/pull/56060#discussion_r1399245221
|
7200 | 7201 | ref_count += 1
|
7201 | 7202 | if ctr <= ref_count:
|
@@ -7477,7 +7478,7 @@ def ffill(
|
7477 | 7478 | elif not PYPY and not using_copy_on_write():
|
7478 | 7479 | ctr = sys.getrefcount(self)
|
7479 | 7480 | ref_count = REF_COUNT
|
7480 |
| - if isinstance(self, ABCSeries) and hasattr(self, "_cacher"): |
| 7481 | + if isinstance(self, ABCSeries) and _check_cacher(self): |
7481 | 7482 | # see https://github.com/pandas-dev/pandas/pull/56060#discussion_r1399245221
|
7482 | 7483 | ref_count += 1
|
7483 | 7484 | if ctr <= ref_count:
|
@@ -7660,7 +7661,7 @@ def bfill(
|
7660 | 7661 | elif not PYPY and not using_copy_on_write():
|
7661 | 7662 | ctr = sys.getrefcount(self)
|
7662 | 7663 | ref_count = REF_COUNT
|
7663 |
| - if isinstance(self, ABCSeries) and hasattr(self, "_cacher"): |
| 7664 | + if isinstance(self, ABCSeries) and _check_cacher(self): |
7664 | 7665 | # see https://github.com/pandas-dev/pandas/pull/56060#discussion_r1399245221
|
7665 | 7666 | ref_count += 1
|
7666 | 7667 | if ctr <= ref_count:
|
@@ -7826,12 +7827,12 @@ def replace(
|
7826 | 7827 | elif not PYPY and not using_copy_on_write():
|
7827 | 7828 | ctr = sys.getrefcount(self)
|
7828 | 7829 | ref_count = REF_COUNT
|
7829 |
| - if isinstance(self, ABCSeries) and hasattr(self, "_cacher"): |
| 7830 | + if isinstance(self, ABCSeries) and _check_cacher(self): |
7830 | 7831 | # in non-CoW mode, chained Series access will populate the
|
7831 | 7832 | # `_item_cache` which results in an increased ref count not below
|
7832 | 7833 | # the threshold, while we still need to warn. We detect this case
|
7833 | 7834 | # of a Series derived from a DataFrame through the presence of
|
7834 |
| - # `_cacher` |
| 7835 | + # checking the `_cacher` |
7835 | 7836 | ref_count += 1
|
7836 | 7837 | if ctr <= ref_count:
|
7837 | 7838 | warnings.warn(
|
@@ -8267,7 +8268,7 @@ def interpolate(
|
8267 | 8268 | elif not PYPY and not using_copy_on_write():
|
8268 | 8269 | ctr = sys.getrefcount(self)
|
8269 | 8270 | ref_count = REF_COUNT
|
8270 |
| - if isinstance(self, ABCSeries) and hasattr(self, "_cacher"): |
| 8271 | + if isinstance(self, ABCSeries) and _check_cacher(self): |
8271 | 8272 | # see https://github.com/pandas-dev/pandas/pull/56060#discussion_r1399245221
|
8272 | 8273 | ref_count += 1
|
8273 | 8274 | if ctr <= ref_count:
|
|
0 commit comments