diff --git a/doc/source/whatsnew/v1.5.1.rst b/doc/source/whatsnew/v1.5.1.rst index d3a804ff9f400..b9477908c6ad9 100644 --- a/doc/source/whatsnew/v1.5.1.rst +++ b/doc/source/whatsnew/v1.5.1.rst @@ -86,6 +86,7 @@ Fixed regressions - Fixed Regression in :meth:`DataFrameGroupBy.apply` when user defined function is called on an empty dataframe (:issue:`47985`) - Fixed regression in :meth:`DataFrame.apply` when passing non-zero ``axis`` via keyword argument (:issue:`48656`) - Fixed regression in :meth:`Series.groupby` and :meth:`DataFrame.groupby` when the grouper is a nullable data type (e.g. :class:`Int64`) or a PyArrow-backed string array, contains null values, and ``dropna=False`` (:issue:`48794`) +- Fixed performance regression in :meth:`Series.isin` with mismatching dtypes (:issue:`49162`) - Fixed regression in :meth:`DataFrame.to_parquet` raising when file name was specified as ``bytes`` (:issue:`48944`) - Fixed regression in :class:`ExcelWriter` where the ``book`` attribute could no longer be set; however setting this attribute is now deprecated and this ability will be removed in a future version of pandas (:issue:`48780`) - Fixed regression in :meth:`DataFrame.corrwith` when computing correlation on tied data with ``method="spearman"`` (:issue:`48826`) diff --git a/pandas/core/algorithms.py b/pandas/core/algorithms.py index 0da9defcf2468..172feb8884b30 100644 --- a/pandas/core/algorithms.py +++ b/pandas/core/algorithms.py @@ -462,12 +462,14 @@ def isin(comps: AnyArrayLike, values: AnyArrayLike) -> npt.NDArray[np.bool_]: ) if not isinstance(values, (ABCIndex, ABCSeries, ABCExtensionArray, np.ndarray)): - if not is_signed_integer_dtype(comps): + orig_values = values + values = _ensure_arraylike(list(values)) + + if is_numeric_dtype(values) and not is_signed_integer_dtype(comps): # GH#46485 Use object to avoid upcast to float64 later # TODO: Share with _find_common_type_compat - values = construct_1d_object_array_from_listlike(list(values)) - else: - values = _ensure_arraylike(list(values)) + values = construct_1d_object_array_from_listlike(list(orig_values)) + elif isinstance(values, ABCMultiIndex): # Avoid raising in extract_array values = np.array(values)