Skip to content

Commit 328d8bd

Browse files
committed
CLN: Standardize searchsorted signatures
The parameter is "value" across the board. xref pandas-devgh-14645.
1 parent 73dd6ec commit 328d8bd

File tree

9 files changed

+2
-17
lines changed

9 files changed

+2
-17
lines changed

doc/source/whatsnew/v0.24.0.txt

+2
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,8 @@ Removal of prior version deprecations/changes
570570
- Strings passed into :meth:`DataFrame.groupby` that refer to both column and index levels will raise a ``ValueError`` (:issue:`14432`)
571571
- :meth:`Index.repeat` and :meth:`MultiIndex.repeat` have renamed the ``n`` argument to ``repeats`` (:issue:`14645`)
572572
- Removal of the previously deprecated ``as_indexer`` keyword completely from ``str.match()`` (:issue:`22356`, :issue:`6581`)
573+
- :meth:`Categorical.searchsorted()` and :meth:`Series.searchsorted()` have renamed the ``v`` argument to ``value`` (:issue:`14645`)
574+
- :meth:`TimedeltaIndex.searchsorted(), :meth:`DatetimeIndex.searchsorted()`, and :meth:`PeriodIndex.searchsorted()` have renamed the ``key`` argument to ``value`` (:issue:`14645`)
573575

574576
.. _whatsnew_0240.performance:
575577

pandas/core/arrays/categorical.py

-1
Original file line numberDiff line numberDiff line change
@@ -1335,7 +1335,6 @@ def memory_usage(self, deep=False):
13351335

13361336
@Substitution(klass='Categorical')
13371337
@Appender(_shared_docs['searchsorted'])
1338-
@deprecate_kwarg(old_arg_name='v', new_arg_name='value')
13391338
def searchsorted(self, value, side='left', sorter=None):
13401339
if not self.ordered:
13411340
raise ValueError("Categorical not ordered\nyou can use "

pandas/core/base.py

-1
Original file line numberDiff line numberDiff line change
@@ -1228,7 +1228,6 @@ def factorize(self, sort=False, na_sentinel=-1):
12281228

12291229
@Substitution(klass='IndexOpsMixin')
12301230
@Appender(_shared_docs['searchsorted'])
1231-
@deprecate_kwarg(old_arg_name='key', new_arg_name='value')
12321231
def searchsorted(self, value, side='left', sorter=None):
12331232
# needs coercion on the key (DatetimeIndex does already)
12341233
return self.values.searchsorted(value, side=side, sorter=sorter)

pandas/core/indexes/period.py

-1
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,6 @@ def astype(self, dtype, copy=True, how='start'):
426426

427427
@Substitution(klass='PeriodIndex')
428428
@Appender(_shared_docs['searchsorted'])
429-
@deprecate_kwarg(old_arg_name='key', new_arg_name='value')
430429
def searchsorted(self, value, side='left', sorter=None):
431430
if isinstance(value, Period):
432431
if value.freq != self.freq:

pandas/core/indexes/timedeltas.py

-1
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,6 @@ def _partial_td_slice(self, key, freq, use_lhs=True, use_rhs=True):
609609

610610
@Substitution(klass='TimedeltaIndex')
611611
@Appender(_shared_docs['searchsorted'])
612-
@deprecate_kwarg(old_arg_name='key', new_arg_name='value')
613612
def searchsorted(self, value, side='left', sorter=None):
614613
if isinstance(value, (np.ndarray, Index)):
615614
value = np.array(value, dtype=_TD_DTYPE, copy=False)

pandas/core/series.py

-1
Original file line numberDiff line numberDiff line change
@@ -2089,7 +2089,6 @@ def __rmatmul__(self, other):
20892089

20902090
@Substitution(klass='Series')
20912091
@Appender(base._shared_docs['searchsorted'])
2092-
@deprecate_kwarg(old_arg_name='v', new_arg_name='value')
20932092
def searchsorted(self, value, side='left', sorter=None):
20942093
if sorter is not None:
20952094
sorter = ensure_platform_int(sorter)

pandas/tests/arrays/categorical/test_analytics.py

-5
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,6 @@ def test_searchsorted(self):
118118
pytest.raises(ValueError, lambda: c2.searchsorted('apple'))
119119
pytest.raises(ValueError, lambda: s2.searchsorted('apple'))
120120

121-
with tm.assert_produces_warning(FutureWarning):
122-
res = c1.searchsorted(v=['bread'])
123-
exp = np.array([3], dtype=np.intp)
124-
tm.assert_numpy_array_equal(res, exp)
125-
126121
def test_unique(self):
127122
# categories are reordered based on value when ordered=False
128123
cat = Categorical(["a", "b"])

pandas/tests/indexes/period/test_tools.py

-3
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,6 @@ def test_searchsorted(self, freq):
220220
with tm.assert_raises_regex(period.IncompatibleFrequency, msg):
221221
pidx.searchsorted(pd.Period('2014-01-01', freq='5D'))
222222

223-
with tm.assert_produces_warning(FutureWarning):
224-
pidx.searchsorted(key=p2)
225-
226223

227224
class TestPeriodIndexConversion(object):
228225
def test_tolist(self):

pandas/tests/series/test_analytics.py

-4
Original file line numberDiff line numberDiff line change
@@ -1368,10 +1368,6 @@ def test_searchsorted(self):
13681368
idx = s.searchsorted(1, side='right')
13691369
tm.assert_numpy_array_equal(idx, np.array([1], dtype=np.intp))
13701370

1371-
with tm.assert_produces_warning(FutureWarning):
1372-
idx = s.searchsorted(v=1, side='left')
1373-
tm.assert_numpy_array_equal(idx, np.array([0], dtype=np.intp))
1374-
13751371
def test_searchsorted_numeric_dtypes_scalar(self):
13761372
s = Series([1, 2, 90, 1000, 3e9])
13771373
r = s.searchsorted(30)

0 commit comments

Comments
 (0)