Skip to content
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

PERF: avoid going through .values for reindexing both index/columns for ArrayManager #44798

Closed
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
6 changes: 5 additions & 1 deletion pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -4675,7 +4675,11 @@ def _reindex_multi(
new_index, row_indexer = self.index.reindex(axes["index"])
new_columns, col_indexer = self.columns.reindex(axes["columns"])

if row_indexer is not None and col_indexer is not None:
if (
row_indexer is not None
and col_indexer is not None
and not isinstance(self._mgr, ArrayManager)
Copy link
Member

Choose a reason for hiding this comment

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

i think a more general condition would be self._can_fast_transpose. The thing we care about is self.values being cheap.

Copy link
Member

Choose a reason for hiding this comment

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

@jorisvandenbossche can you address comments and rebase

):
# Fastpath. By doing two 'take's at once we avoid making an
# unnecessary copy.
# We only get here with `not self._is_mixed_type`, which (almost)
Expand Down