File tree 2 files changed +8
-7
lines changed
2 files changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ from pandas._libs.missing import checknull
27
27
cdef int64_t NPY_NAT = util.get_nat()
28
28
29
29
30
- cdef inline bint is_definitely_invalid_key(object val):
30
+ cpdef inline bint is_definitely_invalid_key(object val):
31
31
if isinstance (val, tuple ):
32
32
try :
33
33
hash (val)
Original file line number Diff line number Diff line change @@ -308,12 +308,13 @@ def has_duplicates(self):
308
308
309
309
@Appender (_index_shared_docs ['get_loc' ])
310
310
def get_loc (self , key , method = None , tolerance = None ):
311
- if method is None and tolerance is None :
312
- try :
313
- return self ._range .index (key )
314
- except ValueError :
315
- raise KeyError (key )
316
- return super ().__get_loc (key , method = method , tolerance = tolerance )
311
+ if not libindex .is_definitely_invalid_key (key ):
312
+ if method is None and tolerance is None :
313
+ try :
314
+ return self ._range .index (key )
315
+ except ValueError :
316
+ raise KeyError (key )
317
+ return super ().get_loc (key , method = method , tolerance = tolerance )
317
318
318
319
def tolist (self ):
319
320
return list (range (self ._start , self ._stop , self ._step ))
You can’t perform that action at this time.
0 commit comments