Skip to content

Commit 2c1b85b

Browse files
committed
shifted KeyError check position
1 parent 2fdacb5 commit 2c1b85b

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

pandas/core/indexing.py

+4-8
Original file line numberDiff line numberDiff line change
@@ -944,8 +944,9 @@ def _handle_lowerdim_multi_index_axis0(self, tup):
944944
except TypeError:
945945
# slices are unhashable
946946
pass
947-
except KeyError:
948-
return None
947+
except KeyError as ek:
948+
if len(tup) > self.obj.ndim:
949+
raise ek
949950
except Exception as e1:
950951
if isinstance(tup[0], (slice, Index)):
951952
raise IndexingError("Handle elsewhere")
@@ -978,12 +979,7 @@ def _getitem_lowerdim(self, tup):
978979
return result
979980

980981
if len(tup) > self.obj.ndim:
981-
try:
982-
self._get_label(tup, axis=self.axis)
983-
except KeyError:
984-
return self._get_label(tup, axis=self.axis)
985-
except Exception:
986-
raise IndexingError("Too many indexers. handle elsewhere")
982+
raise IndexingError("Too many indexers. handle elsewhere")
987983

988984
# to avoid wasted computation
989985
# df.ix[d1:d2, 0] -> columns first (True)

0 commit comments

Comments
 (0)