Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
REF: Defer creating Index._engine until needed
  • Loading branch information
mroeschke committed Apr 22, 2024
commit e38e854f7023cc70c71b3ccf1ff35e9d73448671
3 changes: 1 addition & 2 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -4012,7 +4012,6 @@ def _get_value(self, index, col, takeable: bool = False) -> Scalar:
return series._values[index]

series = self._get_item(col)
engine = self.index._engine

if not isinstance(self.index, MultiIndex):
# CategoricalIndex: Trying to use the engine fastpath may give incorrect
Expand All @@ -4023,7 +4022,7 @@ def _get_value(self, index, col, takeable: bool = False) -> Scalar:

# For MultiIndex going through engine effectively restricts us to
# same-length tuples; see test_get_set_value_no_partial_indexing
loc = engine.get_loc(index)
loc = self.index._engine.get_loc(index)
return series._values[loc]

def isetitem(self, loc, value) -> None:
Expand Down
3 changes: 2 additions & 1 deletion pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,8 @@ def _reset_identity(self) -> None:

@final
def _cleanup(self) -> None:
self._engine.clear_mapping()
if "_engine" in self._cache:
self._engine.clear_mapping()

@cache_readonly
def _engine(
Expand Down