Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7286385

Browse files
meeseeksmachinephofl
andauthored
Backport PR #49162 on branch 1.5.x (PERF: Fix performance regression for isin with mismatching dtypes) (#49165)
Backport PR #49162: PERF: Fix performance regression for isin with mismatching dtypes Co-authored-by: Patrick Hoefler <61934744+phofl@users.noreply.github.com>
1 parent 8429c50 commit 7286385

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

‎doc/source/whatsnew/v1.5.1.rst‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ Fixed regressions
8686
- Fixed Regression in :meth:`DataFrameGroupBy.apply` when user defined function is called on an empty dataframe (:issue:`47985`)
8787
- Fixed regression in :meth:`DataFrame.apply` when passing non-zero ``axis`` via keyword argument (:issue:`48656`)
8888
- 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`)
89+
- Fixed performance regression in :meth:`Series.isin` with mismatching dtypes (:issue:`49162`)
8990
- Fixed regression in :meth:`DataFrame.to_parquet` raising when file name was specified as ``bytes`` (:issue:`48944`)
9091
- 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`)
9192
- Fixed regression in :meth:`DataFrame.corrwith` when computing correlation on tied data with ``method="spearman"`` (:issue:`48826`)

‎pandas/core/algorithms.py‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -462,12 +462,14 @@ def isin(comps: AnyArrayLike, values: AnyArrayLike) -> npt.NDArray[np.bool_]:
462462
)
463463

464464
if not isinstance(values, (ABCIndex, ABCSeries, ABCExtensionArray, np.ndarray)):
465-
if not is_signed_integer_dtype(comps):
465+
orig_values = values
466+
values = _ensure_arraylike(list(values))
467+
468+
if is_numeric_dtype(values) and not is_signed_integer_dtype(comps):
466469
# GH#46485 Use object to avoid upcast to float64 later
467470
# TODO: Share with _find_common_type_compat
468-
values = construct_1d_object_array_from_listlike(list(values))
469-
else:
470-
values = _ensure_arraylike(list(values))
471+
values = construct_1d_object_array_from_listlike(list(orig_values))
472+
471473
elif isinstance(values, ABCMultiIndex):
472474
# Avoid raising in extract_array
473475
values = np.array(values)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /