Skip to content

Commit bcbe226

Browse files
committed
cleanups
1 parent 9e6ed43 commit bcbe226

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

doc/source/whatsnew/v0.25.0.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Performance Improvements
6565
- Significant speedup in `SparseArray` initialization that benefits most operations, fixing performance regression introduced in v0.20.0 (:issue:`24985`)
6666
- `DataFrame.to_stata()` is now faster when outputting data with any string or non-native endian columns (:issue:`25045`)
6767
- Improved performance of :meth:`Series.searchsorted`. The speedup is especially large when the dtype is
68-
int8/int16/int32 and the searched key is within the integer bounds for the dtype(:issue:`22034`)
68+
int8/int16/int32 and the searched key is within the integer bounds for the dtype (:issue:`22034`)
6969

7070

7171
.. _whatsnew_0250.bug_fixes:

pandas/core/algorithms.py

+9-8
Original file line numberDiff line numberDiff line change
@@ -1734,24 +1734,25 @@ def searchsorted(arr, value, side="left", sorter=None):
17341734
17351735
.. versionadded:: 0.25.0
17361736
1737-
Find the indices into a sorted array `self` (a) such that, if the
1737+
Find the indices into a sorted array `arr` (a) such that, if the
17381738
corresponding elements in `value` were inserted before the indices,
1739-
the order of `self` would be preserved.
1739+
the order of `arr` would be preserved.
17401740
1741-
Assuming that `self` is sorted:
1741+
Assuming that `arr` is sorted:
17421742
17431743
====== ================================
17441744
`side` returned index `i` satisfies
17451745
====== ================================
1746-
left ``self[i-1] < value <= self[i]``
1747-
right ``self[i-1] <= value < self[i]``
1746+
left ``arr[i-1] < value <= self[i]``
1747+
right ``arr[i-1] <= value < self[i]``
17481748
====== ================================
17491749
17501750
Parameters
17511751
----------
1752-
arr: numpy.array or ExtensionArray
1753-
array to search in. Cannot be Index, Series or PandasArray, as that
1754-
would cause a RecursionError.
1752+
arr: array-like
1753+
Input array. If `sorter` is None, then it must be sorted in
1754+
ascending order, otherwise `sorter` must be an array of indices
1755+
that sort it.
17551756
value : array_like
17561757
Values to insert into `arr`.
17571758
side : {'left', 'right'}, optional

pandas/tests/arrays/test_array.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -285,9 +285,15 @@ def test_searchsorted_numeric_dtypes_vector(self, any_real_dtype):
285285
expected = np.array([1, 2], dtype=np.intp)
286286
tm.assert_numpy_array_equal(result, expected)
287287

288-
def test_search_sorted_datetime64_scalar(self):
289-
arr = pd.array(pd.date_range('20120101', periods=10, freq='2D'))
290-
val = pd.Timestamp('20120102')
288+
@pytest.mark.parametrize('arr, val', [
289+
[pd.date_range('20120101', periods=10, freq='2D'),
290+
pd.Timestamp('20120102')],
291+
[pd.date_range('20120101', periods=10, freq='2D', tz='Asia/Hong_Kong'),
292+
pd.Timestamp('20120102', tz='Asia/Hong_Kong')],
293+
[pd.timedelta_range(start='1 day', end='10 days', periods=10),
294+
pd.Timedelta('2 days')]])
295+
def test_search_sorted_datetime64_scalar(self, arr, val):
296+
arr = pd.array(arr)
291297
result = arr.searchsorted(val)
292298
assert is_scalar(result)
293299
assert result == 1

0 commit comments

Comments
 (0)