Skip to content

INT: Use Index._getitem_slice in ArrayManager #40369

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 12, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions pandas/core/internals/array_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -793,12 +793,10 @@ def get_slice(self, slobj: slice, axis: int = 0) -> ArrayManager:
arrays = self.arrays[slobj]

new_axes = list(self._axes)
new_axes[axis] = new_axes[axis][slobj]
new_axes[axis] = new_axes[axis]._getitem_slice(slobj)

return type(self)(arrays, new_axes, verify_integrity=False)

getitem_mgr = get_slice

def fast_xs(self, loc: int) -> ArrayLike:
"""
Return the array corresponding to `frame.iloc[loc]`.
Expand Down Expand Up @@ -1235,7 +1233,12 @@ def get_slice(self, slobj: slice, axis: int = 0) -> SingleArrayManager:
raise IndexError("Requested axis not found in manager")

new_array = self.array[slobj]
new_index = self.index[slobj]
new_index = self.index._getitem_slice(slobj)
return type(self)([new_array], [new_index], verify_integrity=False)

def getitem_mgr(self, indexer) -> SingleArrayManager:
new_array = self.array[indexer]
new_index = self.index[indexer]
return type(self)([new_array], [new_index])

def apply(self, func, **kwargs):
Expand Down