Skip to content

Commit 5416711

Browse files
committed
Cleaned removed ifs for int_flg and float_flg
1 parent b71dad6 commit 5416711

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

pandas/core/algorithms.py

+7-10
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,7 @@ def isin(comps, values):
420420

421421
is_time_like = lambda x: (is_datetime_or_timedelta_dtype(x)
422422
or isinstance(x, Timestamp))
423+
423424
if is_time_like(dtype):
424425
values, _, _ = _ensure_data(values, dtype=dtype)
425426
else:
@@ -428,24 +429,20 @@ def isin(comps, values):
428429
# faster for larger cases to use np.in1d
429430
f = lambda x, y: htable.ismember_object(x.astype(object), y.astype(object))
430431

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)
435434

436435
is_int = lambda x: ((x == np.int64) or (x == int))
437436
is_float = lambda x: ((x == np.float64) or (x == float))
438437

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
441440

442441
if len(comps_types) == len(values_types) == 1:
443442
comps_types = comps_types.pop()
444443
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))
449446

450447
# GH16012
451448
# Ensure np.in1d doesn't get object types or it *may* throw an exception

0 commit comments

Comments
 (0)