From 9ad143ea405c3477134576aba22787475334ff4a Mon Sep 17 00:00:00 2001 From: Joris Van den Bossche Date: Mon, 6 Dec 2021 21:54:36 +0100 Subject: [PATCH] PERF: avoid going through .values for reindexing both index/columns for ArrayManager --- pandas/core/frame.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 01f817300a01a..80cecedea9848 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -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) + ): # 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)