Skip to content

Commit a293738

Browse files
committed
guard against invalid key
1 parent 03acfff commit a293738

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pandas/core/indexes/range.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -308,12 +308,12 @@ def has_duplicates(self):
308308

309309
@Appender(_index_shared_docs['get_loc'])
310310
def get_loc(self, key, method=None, tolerance=None):
311-
if method is None and tolerance is None:
311+
if is_integer(key) and method is None and tolerance is None:
312312
try:
313313
return self._range.index(key)
314314
except ValueError:
315315
raise KeyError(key)
316-
return super().__get_loc(key, method=method, tolerance=tolerance)
316+
return super().get_loc(key, method=method, tolerance=tolerance)
317317

318318
def tolist(self):
319319
return list(range(self._start, self._stop, self._step))

0 commit comments

Comments
 (0)