Skip to content

Commit af578f5

Browse files
committed
PERF: always use hash-map for isin rather than np.isin1d
1 parent 1f42d45 commit af578f5

File tree

1 file changed

+1
-11
lines changed

1 file changed

+1
-11
lines changed

pandas/core/algorithms.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -433,19 +433,9 @@ def isin(comps: AnyArrayLike, values: AnyArrayLike) -> np.ndarray:
433433
comps, dtype = _ensure_data(comps)
434434
values, _ = _ensure_data(values, dtype=dtype)
435435

436-
# faster for larger cases to use np.in1d
437436
f = htable.ismember_object
438437

439-
# GH16012
440-
# Ensure np.in1d doesn't get object types or it *may* throw an exception
441-
if len(comps) > 1_000_000 and not is_object_dtype(comps):
442-
# If the the values include nan we need to check for nan explicitly
443-
# since np.nan it not equal to np.nan
444-
if isna(values).any():
445-
f = lambda c, v: np.logical_or(np.in1d(c, v), np.isnan(c))
446-
else:
447-
f = np.in1d
448-
elif is_integer_dtype(comps):
438+
if is_integer_dtype(comps):
449439
try:
450440
values = values.astype("int64", copy=False)
451441
comps = comps.astype("int64", copy=False)

0 commit comments

Comments
 (0)