Skip to content

Commit 63a5f15

Browse files
committed
Remove flgs
1 parent 52f8131 commit 63a5f15

File tree

1 file changed

+10
-20
lines changed

1 file changed

+10
-20
lines changed

pandas/core/algorithms.py

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -421,46 +421,36 @@ def isin(comps, values):
421421
is_time_like = lambda x: (is_datetime_or_timedelta_dtype(x)
422422
or isinstance(x, Timestamp))
423423

424+
is_int = lambda x: ((x == np.int64) or (x == int))
425+
is_float = lambda x: ((x == np.float64) or (x == float))
426+
424427
if is_time_like(dtype):
425428
values, _, _ = _ensure_data(values, dtype=dtype)
426429
else:
427430
values, _, _ = _ensure_data(values)
428431

429-
# faster for larger cases to use np.in1d
430-
f = lambda x, y: htable.ismember_object(x, y)
431-
432432
comps_types = set(type(v) for v in comps)
433433
values_types = set(type(v) for v in values)
434434

435-
if len(comps_types) == len(values_types) == 1:
436-
comps_types = comps_types.pop()
437-
values_types = values_types.pop()
438-
439-
is_int = lambda x: ((x == np.int64) or (x == int))
440-
is_float = lambda x: ((x == np.float64) or (x == float))
435+
# faster for larger cases to use np.in1d
436+
f = lambda x, y: htable.ismember_object(x.astype(object), y.astype(object))
441437

442438
# GH16012
443439
# Ensure np.in1d doesn't get object types or it *may* throw an exception
444440
if len(comps) > 1000000 and not is_object_dtype(comps):
445441
f = lambda x, y: np.in1d(x, y)
446-
elif (is_int(comps_types) and is_int(values_types)):
447-
try:
442+
elif len(comps_types) == len(values_types) == 1:
443+
comps_types = comps_types.pop()
444+
values_types = values_types.pop()
445+
if (is_int(comps_types) and is_int(values_types)):
448446
values = values.astype('int64', copy=False)
449447
comps = comps.astype('int64', copy=False)
450448
f = lambda x, y: htable.ismember_int64(x, y)
451-
except (TypeError, ValueError):
452-
values = values.astype(object)
453-
comps = comps.astype(object)
454-
455-
elif (is_float(comps_types) and is_float(values_types)):
456-
try:
449+
elif (is_float(comps_types) and is_float(values_types)):
457450
values = values.astype('float64', copy=False)
458451
comps = comps.astype('float64', copy=False)
459452
checknull = isna(values).any()
460453
f = lambda x, y: htable.ismember_float64(x, y, checknull)
461-
except (TypeError, ValueError):
462-
values = values.astype(object)
463-
comps = comps.astype(object)
464454

465455
return f(comps, values)
466456

0 commit comments

Comments
 (0)