Skip to content

Commit eb9f65c

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

File tree

10 files changed

+7
-27
lines changed

10 files changed

+7
-27
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-3
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@
2424
import pandas._libs.lib as lib
2525
from pandas.compat.numpy import function as nv
2626
from pandas.compat import PYPY, OrderedDict
27-
from pandas.util._decorators import (Appender, cache_readonly,
28-
deprecate_kwarg, Substitution)
27+
from pandas.util._decorators import Appender, cache_readonly, Substitution
2928

3029
from pandas.core.accessor import DirNamesMixin
3130

@@ -1228,7 +1227,6 @@ def factorize(self, sort=False, na_sentinel=-1):
12281227

12291228
@Substitution(klass='IndexOpsMixin')
12301229
@Appender(_shared_docs['searchsorted'])
1231-
@deprecate_kwarg(old_arg_name='key', new_arg_name='value')
12321230
def searchsorted(self, value, side='left', sorter=None):
12331231
# needs coercion on the key (DatetimeIndex does already)
12341232
return self.values.searchsorted(value, side=side, sorter=sorter)

pandas/core/indexes/datetimes.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@
4343
generate_range, CDay, prefix_mapping)
4444

4545
from pandas.core.tools.timedeltas import to_timedelta
46-
from pandas.util._decorators import (
47-
Appender, cache_readonly, deprecate_kwarg, Substitution)
46+
from pandas.util._decorators import Appender, cache_readonly, Substitution
4847
import pandas.core.common as com
4948
import pandas.tseries.offsets as offsets
5049
import pandas.core.tools.datetimes as tools
@@ -1375,7 +1374,6 @@ def normalize(self):
13751374

13761375
@Substitution(klass='DatetimeIndex')
13771376
@Appender(_shared_docs['searchsorted'])
1378-
@deprecate_kwarg(old_arg_name='key', new_arg_name='value')
13791377
def searchsorted(self, value, side='left', sorter=None):
13801378
if isinstance(value, (np.ndarray, Index)):
13811379
value = np.array(value, dtype=_NS_DTYPE, copy=False)

pandas/core/indexes/period.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@
3636
from pandas.core.indexes.base import _index_shared_docs, ensure_index
3737

3838
from pandas import compat
39-
from pandas.util._decorators import (Appender, Substitution, cache_readonly,
40-
deprecate_kwarg)
39+
from pandas.util._decorators import Appender, Substitution, cache_readonly
4140

4241
import pandas.core.indexes.base as ibase
4342
_index_doc_kwargs = dict(ibase._index_doc_kwargs)
@@ -426,7 +425,6 @@ def astype(self, dtype, copy=True, how='start'):
426425

427426
@Substitution(klass='PeriodIndex')
428427
@Appender(_shared_docs['searchsorted'])
429-
@deprecate_kwarg(old_arg_name='key', new_arg_name='value')
430428
def searchsorted(self, value, side='left', sorter=None):
431429
if isinstance(value, Period):
432430
if value.freq != self.freq:

pandas/core/indexes/timedeltas.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
from pandas.core.indexes.base import _index_shared_docs
3030
import pandas.core.common as com
3131
import pandas.core.dtypes.concat as _concat
32-
from pandas.util._decorators import Appender, Substitution, deprecate_kwarg
32+
from pandas.util._decorators import Appender, Substitution
3333
from pandas.core.indexes.datetimelike import (
3434
TimelikeOps, DatetimeIndexOpsMixin, wrap_arithmetic_op)
3535
from pandas.core.tools.timedeltas import (
@@ -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-3
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@
7575
import pandas.core.indexes.base as ibase
7676

7777
import pandas.io.formats.format as fmt
78-
from pandas.util._decorators import (
79-
Appender, deprecate, deprecate_kwarg, Substitution)
78+
from pandas.util._decorators import Appender, deprecate, Substitution
8079
from pandas.util._validators import validate_bool_kwarg
8180

8281
from pandas._libs import index as libindex, tslibs, lib, iNaT
@@ -2089,7 +2088,6 @@ def __rmatmul__(self, other):
20892088

20902089
@Substitution(klass='Series')
20912090
@Appender(base._shared_docs['searchsorted'])
2092-
@deprecate_kwarg(old_arg_name='v', new_arg_name='value')
20932091
def searchsorted(self, value, side='left', sorter=None):
20942092
if sorter is not None:
20952093
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)