@@ -420,6 +420,7 @@ def isin(comps, values):
420
420
421
421
is_time_like = lambda x : (is_datetime_or_timedelta_dtype (x )
422
422
or isinstance (x , Timestamp ))
423
+
423
424
if is_time_like (dtype ):
424
425
values , _ , _ = _ensure_data (values , dtype = dtype )
425
426
else :
@@ -428,24 +429,20 @@ def isin(comps, values):
428
429
# faster for larger cases to use np.in1d
429
430
f = lambda x , y : htable .ismember_object (x .astype (object ), y .astype (object ))
430
431
431
- # This block checks if comps and values
432
- # are all int or all float
433
- int_flg = False
434
- float_flg = False
432
+ comps_types = set (type (v ) for v in comps )
433
+ values_types = set (type (v ) for v in values )
435
434
436
435
is_int = lambda x : ((x == np .int64 ) or (x == int ))
437
436
is_float = lambda x : ((x == np .float64 ) or (x == float ))
438
437
439
- comps_types = set ( type ( v ) for v in comps )
440
- values_types = set ( type ( v ) for v in values )
438
+ int_flg = False
439
+ float_flg = False
441
440
442
441
if len (comps_types ) == len (values_types ) == 1 :
443
442
comps_types = comps_types .pop ()
444
443
values_types = values_types .pop ()
445
- if (is_int (comps_types ) and is_int (values_types )):
446
- int_flg = True
447
- elif (is_float (comps_types ) and is_float (values_types )):
448
- float_flg = True
444
+ int_flg = (is_int (comps_types ) and is_int (values_types ))
445
+ float_flg = (is_float (comps_types ) and is_float (values_types ))
449
446
450
447
# GH16012
451
448
# Ensure np.in1d doesn't get object types or it *may* throw an exception
0 commit comments