Skip to content

Commit d0fbc0b

Browse files
committed
Fix PandasObject cache attribute name
1 parent c4b997e commit d0fbc0b

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

pandas/core/base.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,9 @@ class PandasObject(DirNamesMixin):
8080
Baseclass for various pandas objects.
8181
"""
8282

83-
# results from calls to methods decorated with cache_readonly get added to _cache
84-
_cache: Dict[str, Any]
83+
# results from calls to methods decorated with
84+
# cache_readonly get added to _cache_property
85+
_cache_property: Dict[str, Any]
8586

8687
@property
8788
def _constructor(self):
@@ -101,12 +102,12 @@ def _reset_cache(self, key: Optional[str] = None) -> None:
101102
"""
102103
Reset cached properties. If ``key`` is passed, only clears that key.
103104
"""
104-
if not hasattr(self, "_cache"):
105+
if not hasattr(self, "_cache_property"):
105106
return
106107
if key is None:
107-
self._cache.clear()
108+
self._cache_property.clear()
108109
else:
109-
self._cache.pop(key, None)
110+
self._cache_property.pop(key, None)
110111

111112
def __sizeof__(self) -> int:
112113
"""

pandas/tests/series/test_missing.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,10 @@ def test_hasnans_uncached_for_series():
103103
# GH#19700
104104
idx = Index([0, 1])
105105
assert idx.hasnans is False
106-
assert "hasnans" in idx._cache
106+
assert "hasnans" in idx._cache_property
107107
ser = idx.to_series()
108108
assert ser.hasnans is False
109-
assert not hasattr(ser, "_cache")
109+
assert not hasattr(ser, "_cache_property")
110110
ser.iloc[-1] = np.nan
111111
assert ser.hasnans is True
112112
assert Series.hasnans.__doc__ == Index.hasnans.__doc__

0 commit comments

Comments
 (0)