Skip to content

REF: stricter typing in Manager.take #51478

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 1 commit into from
Feb 20, 2023

Conversation

jbrockmendel
Copy link
Member

Handle the slice case at at the ndframe level; in future passes I'd like to avoid allowing slices in .take altogether.

@@ -3915,6 +3916,11 @@ def _take(
and is_range_indexer(indices, len(self))
):
return self.copy(deep=None)
else:
# We can get here with a slice via DataFrame.__geittem__
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in getitem

Is this a column or row-based slice?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

column

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mind if i add the typo fix to my next Assorted CLN branch?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

id like to add a check for slice in __getitem__ before we get here to return self._slice(indexer) instead, but that may (probably should) cause us to return a view instead of copy.

Once that is changed, I'd like to deprecate allowing slice in DataFrame.take (which we don't allow in Series.take). It isn't documented, but still.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah fine by me.

Take returns a view for CoW even if it’s not a slice iirc. deprecating sounds good though.

@phofl phofl added Refactor Internal refactoring of code Internals Related to non-user accessible pandas implementation labels Feb 20, 2023
@phofl phofl added this to the 2.1 milestone Feb 20, 2023
@phofl phofl merged commit 8ae8173 into pandas-dev:main Feb 20, 2023
@phofl
Copy link
Member

phofl commented Feb 20, 2023

thx @jbrockmendel

@jbrockmendel jbrockmendel deleted the ref-take-strict branch February 20, 2023 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Internals Related to non-user accessible pandas implementation Refactor Internal refactoring of code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants