Skip to content

Commit a153330

Browse files
author
David John Gagne
committed
BUG: pandas-dev#10610 Altered index checking to use existing checks to raise IndexError.
1 parent e01e5cc commit a153330

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

pandas/core/index.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -971,11 +971,12 @@ def _convert_list_indexer(self, keyarr, kind=None):
971971

972972
if self.inferred_type == 'mixed-integer':
973973
indexer = self.get_indexer(keyarr)
974-
if not np.all(np.in1d(indexer, self.values)):
975-
raise IndexError("At least one item not found in index.")
976974
if (indexer >= 0).all():
977975
return indexer
978-
976+
# missing values are flagged as -1 by get_indexer and negative indices are already
977+
# converted to positive indices in the above if-statement, so the negative flags are changed to
978+
# values outside the range of indices so as to trigger an IndexError in maybe_convert_indices
979+
indexer[indexer < 0] = len(self)
979980
from pandas.core.indexing import maybe_convert_indices
980981
return maybe_convert_indices(indexer, len(self))
981982

0 commit comments

Comments
 (0)