diff --git a/doc/source/whatsnew/v0.25.0.rst b/doc/source/whatsnew/v0.25.0.rst index aaf4fd028527b9..debe605cb88be7 100644 --- a/doc/source/whatsnew/v0.25.0.rst +++ b/doc/source/whatsnew/v0.25.0.rst @@ -63,8 +63,8 @@ Performance Improvements - Significant speedup in `SparseArray` initialization that benefits most operations, fixing performance regression introduced in v0.20.0 (:issue:`24985`) - `DataFrame.to_stata()` is now faster when outputting data with any string or non-native endian columns (:issue:`25045`) -- Improved performance of :meth:`Series.searchsorted`. The speedup is especially large when the dtype is int8/int16/int32 and the searched key is within - the integer bounds for the dtype(:issue:`22034`) +- Improved performance of :meth:`Series.searchsorted`. The speedup is especially large when the dtype is + int8/int16/int32 and the searched key is within the integer bounds for the dtype(:issue:`22034`) .. _whatsnew_0250.bug_fixes: diff --git a/pandas/core/algorithms.py b/pandas/core/algorithms.py index 1430b07f4e1ede..6413768068d18a 100644 --- a/pandas/core/algorithms.py +++ b/pandas/core/algorithms.py @@ -1724,9 +1724,9 @@ def func(arr, indexer, out, fill_value=np.nan): return out -# ---- # +# ------------ # # searchsorted # -# ---- # +# ------------ # def searchsorted(arr, value, side="left", sorter=None): """ @@ -1774,7 +1774,7 @@ def searchsorted(arr, value, side="left", sorter=None): if sorter is not None: sorter = ensure_platform_int(sorter) - if is_integer_dtype(arr) and ( + if isinstance(arr, np.ndarray) and is_integer_dtype(arr) and ( is_integer(value) or is_integer_dtype(value)): from .arrays.array_ import array # if `arr` and `value` have different dtypes, `arr` would be diff --git a/pandas/core/common.py b/pandas/core/common.py index 1c78a5f4747981..0e92a5056daae8 100644 --- a/pandas/core/common.py +++ b/pandas/core/common.py @@ -12,6 +12,7 @@ import numpy as np from pandas._libs import lib, tslibs +import pandas.compat as compat from pandas.compat import PY36, OrderedDict, iteritems from pandas.core.dtypes.cast import construct_1d_object_array_from_listlike @@ -21,8 +22,6 @@ from pandas.core.dtypes.inference import _iterable_not_string from pandas.core.dtypes.missing import isna, isnull, notnull # noqa -from pandas import compat - class SettingWithCopyError(ValueError): pass