Skip to content

REF: de-duplicate NDFrame.take, remove Manager.take keyword #51482

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 3 commits into from
Feb 21, 2023

Conversation

jbrockmendel
Copy link
Member

  • closes #xxxx (Replace xxxx with the GitHub issue number)
  • Tests added and passed if fixing a bug or adding a new feature
  • All code checks passed.
  • Added type annotations to new arguments/methods/functions.
  • Added an entry in the latest doc/source/whatsnew/vX.X.X.rst file if fixing a bug or adding a new feature.

@@ -3916,8 +3903,14 @@ def _take(
and is_range_indexer(indices, len(self))
):
return self.copy(deep=None)
elif self.ndim == 1:
# TODO: be consistent here for DataFrame vs Series
Copy link
Member Author

Choose a reason for hiding this comment

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

@phofl following this ill do do the deprecation we discussed

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good!

@phofl phofl added the Refactor Internal refactoring of code label Feb 21, 2023
@phofl phofl added this to the 2.1 milestone Feb 21, 2023
@phofl phofl merged commit d2dc56f into pandas-dev:main Feb 21, 2023
@phofl
Copy link
Member

phofl commented Feb 21, 2023

thx @jbrockmendel

@jbrockmendel jbrockmendel deleted the ref-take branch February 21, 2023 15:29
@phofl
Copy link
Member

phofl commented Feb 25, 2023

@jbrockmendel Looks like this could have caused a performance regression. https://asv-runner.github.io/asv-collection/pandas/#indexing.NumericSeriesIndexing.time_iloc_array?p-index_structure='unique_monotonic_inc'&p-dtype=%3Cclass%20'numpy.int64'%3E

Could not reproduce locally though, do you have an idea?

@jbrockmendel
Copy link
Member Author

It's plausible. This PR makes us go through Manager.take whereas the old version operated directly on ._values/.index. In retrospect its not that surprising, though I'd have hoped for the effect to be smaller.

Restoring Series.take (the rest of this should be OK) should fix it.

If we go for something like ExtensionManager mentioned in #51471 then we'd need to have basically everything go through a Manager method, in which case we'd need to optimize Manager.take somehow.

@phofl
Copy link
Member

phofl commented Feb 25, 2023

Yep adding Series.take back would get performance back, but as you said not really a long term solution unfortunately

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Refactor Internal refactoring of code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants