Skip to content

Commit 9fd0ea6

Browse files
committed
ENH: Do not build the indexer twice
1 parent fe5a6ff commit 9fd0ea6

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

pandas/core/indexing.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,9 +1112,10 @@ def _getitem_iterable(self, key, axis=None):
11121112
ax = self.obj._get_axis(axis)
11131113
# existing labels are unique and indexer are unique
11141114
if labels.is_unique and Index(keyarr).is_unique:
1115-
self._validate_read_indexer(key, ax.get_indexer_for(key), axis)
1115+
indexer = ax.get_indexer_for(key)
1116+
self._validate_read_indexer(key, indexer, axis)
11161117

1117-
d = {axis: [ax.reindex(keyarr)[0], ax.get_indexer_for(key)]}
1118+
d = {axis: [ax.reindex(keyarr)[0], indexer]}
11181119
return self.obj._reindex_with_indexers(d, copy=True,
11191120
allow_dups=True)
11201121

0 commit comments

Comments
 (0)