We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 672575f commit dbe3673Copy full SHA for dbe3673
pandas/core/algorithms.py
@@ -552,9 +552,8 @@ def isin(comps: ListLike, values: ListLike) -> npt.NDArray[np.bool_]:
552
# Ensure values don't contain <NA>, otherwise it throws exception with np.in1d
553
values_contains_NA = False
554
555
- if values.size != 0:
556
- vectorized_check = np.vectorize(lambda v: v is NA)
557
- values_contains_NA = vectorized_check(values).any()
+ if comps_array.dtype != object and len(values) <= 26:
+ values_contains_NA = any(v is NA for v in values)
558
559
if (
560
len(comps_array) > _MINIMUM_COMP_ARR_LEN
pandas/tests/series/methods/test_isin.py
@@ -214,7 +214,9 @@ def test_isin_large_series_mixed_dtypes_and_nan(monkeypatch):
214
@pytest.mark.parametrize("dtype, data, values, expected", [
215
("boolean", [pd.NA, False, True], [False, pd.NA], [True, True, False]),
216
("Int64", [pd.NA, 2, 1], [1, pd.NA], [True, False, True]),
217
- ("Float64", [20.0, 30.0, pd.NA], [pd.NA], [False, False, True])
+ ("boolean", [pd.NA, False, True], [pd.NA, True, 'a', 20], [True, False, True]),
218
+ ("boolean", [pd.NA, False, True], [], [False, False, False]),
219
+ ("Float64", [20.0, 30.0, pd.NA], [pd.NA], [False, False, True]),
220
])
221
def test_isin_large_series_and_pdNA(dtype, data, values, expected, monkeypatch):
222
# https://github.com/pandas-dev/pandas/issues/60678
0 commit comments