Skip to content

Commit e76a39c

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

File tree

1 file changed

+1
-12
lines changed

1 file changed

+1
-12
lines changed

pandas/core/algorithms.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -433,19 +433,8 @@ 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
438-
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 np.isnan(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):
437+
if is_integer_dtype(comps):
449438
try:
450439
values = values.astype("int64", copy=False)
451440
comps = comps.astype("int64", copy=False)

0 commit comments

Comments
 (0)