diff --git a/pandas/core/indexes/multi.py b/pandas/core/indexes/multi.py index c3d4ad721c830..ceb71d0b9fbb9 100644 --- a/pandas/core/indexes/multi.py +++ b/pandas/core/indexes/multi.py @@ -1302,7 +1302,7 @@ def _view(self) -> MultiIndex: verify_integrity=False, ) result._cache = self._cache.copy() - result._cache.pop("levels", None) # GH32669 + result._reset_cache("levels") # GH32669 return result # -------------------------------------------------------------------- @@ -1384,7 +1384,7 @@ def copy( # type: ignore[override] verify_integrity=False, ) new_index._cache = self._cache.copy() - new_index._cache.pop("levels", None) # GH32669 + new_index._reset_cache("levels") # GH32669 if keep_id: new_index._id = self._id return new_index diff --git a/pandas/core/internals/managers.py b/pandas/core/internals/managers.py index c42ea44b2fc89..bade5fd1bdcf2 100644 --- a/pandas/core/internals/managers.py +++ b/pandas/core/internals/managers.py @@ -2154,7 +2154,7 @@ def setitem_inplace(self, indexer, value) -> None: """ if not self._has_no_reference(0): self.blocks = (self._block.copy(),) - self._cache.clear() + self._reset_cache() arr = self.array @@ -2179,7 +2179,7 @@ def idelete(self, indexer) -> SingleBlockManager: nb = self._block.delete(indexer)[0] self.blocks = (nb,) self.axes[0] = self.axes[0].delete(indexer) - self._cache.clear() + self._reset_cache() return self def fast_xs(self, loc):