Skip to content

Commit 8248536

Browse files
committed
Guard against IntegerArray + cleanups
1 parent c8bc02c commit 8248536

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

doc/source/whatsnew/v0.25.0.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ Performance Improvements
6363

6464
- Significant speedup in `SparseArray` initialization that benefits most operations, fixing performance regression introduced in v0.20.0 (:issue:`24985`)
6565
- `DataFrame.to_stata()` is now faster when outputting data with any string or non-native endian columns (:issue:`25045`)
66-
- Improved performance of :meth:`Series.searchsorted`. The speedup is especially large when the dtype is int8/int16/int32 and the searched key is within
67-
the integer bounds for the dtype(:issue:`22034`)
66+
- Improved performance of :meth:`Series.searchsorted`. The speedup is especially large when the dtype is
67+
int8/int16/int32 and the searched key is within the integer bounds for the dtype(:issue:`22034`)
6868

6969

7070
.. _whatsnew_0250.bug_fixes:

pandas/core/algorithms.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1724,9 +1724,9 @@ def func(arr, indexer, out, fill_value=np.nan):
17241724
return out
17251725

17261726

1727-
# ---- #
1727+
# ------------ #
17281728
# searchsorted #
1729-
# ---- #
1729+
# ------------ #
17301730

17311731
def searchsorted(arr, value, side="left", sorter=None):
17321732
"""
@@ -1774,7 +1774,7 @@ def searchsorted(arr, value, side="left", sorter=None):
17741774
if sorter is not None:
17751775
sorter = ensure_platform_int(sorter)
17761776

1777-
if is_integer_dtype(arr) and (
1777+
if isinstance(arr, np.ndarray) and is_integer_dtype(arr) and (
17781778
is_integer(value) or is_integer_dtype(value)):
17791779
from .arrays.array_ import array
17801780
# if `arr` and `value` have different dtypes, `arr` would be

pandas/core/common.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import numpy as np
1313

1414
from pandas._libs import lib, tslibs
15+
import pandas.compat as compat
1516
from pandas.compat import PY36, OrderedDict, iteritems
1617

1718
from pandas.core.dtypes.cast import construct_1d_object_array_from_listlike
@@ -21,8 +22,6 @@
2122
from pandas.core.dtypes.inference import _iterable_not_string
2223
from pandas.core.dtypes.missing import isna, isnull, notnull # noqa
2324

24-
from pandas import compat
25-
2625

2726
class SettingWithCopyError(ValueError):
2827
pass

0 commit comments

Comments
 (0)