Skip to content

Commit 07291ea

Browse files
committed
Guard against IntegerArray + cleanups
1 parent 093c2be commit 07291ea

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

doc/source/whatsnew/v0.25.0.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ Performance Improvements
6060

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

6666

6767
.. _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

+2-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
import numpy as np
1414

1515
from pandas._libs import lib, tslibs
16-
from pandas.compat import PY36, OrderedDict, iteritems
16+
import pandas.compat as compat
17+
from pandas.compat import PY36, iteritems
1718

1819
from pandas.core.dtypes.cast import construct_1d_object_array_from_listlike
1920
from pandas.core.dtypes.common import (
@@ -22,8 +23,6 @@
2223
from pandas.core.dtypes.inference import _iterable_not_string
2324
from pandas.core.dtypes.missing import isna, isnull, notnull # noqa
2425

25-
from pandas import compat
26-
2726

2827
class SettingWithCopyError(ValueError):
2928
pass

0 commit comments

Comments
 (0)