diff --git a/doc/source/whatsnew/v0.24.0.txt b/doc/source/whatsnew/v0.24.0.txt index 3660c1e843f6c..8d826a5d7d2e7 100644 --- a/doc/source/whatsnew/v0.24.0.txt +++ b/doc/source/whatsnew/v0.24.0.txt @@ -570,6 +570,8 @@ Removal of prior version deprecations/changes - Strings passed into :meth:`DataFrame.groupby` that refer to both column and index levels will raise a ``ValueError`` (:issue:`14432`) - :meth:`Index.repeat` and :meth:`MultiIndex.repeat` have renamed the ``n`` argument to ``repeats`` (:issue:`14645`) - Removal of the previously deprecated ``as_indexer`` keyword completely from ``str.match()`` (:issue:`22356`, :issue:`6581`) +- :meth:`Categorical.searchsorted()` and :meth:`Series.searchsorted()` have renamed the ``v`` argument to ``value`` (:issue:`14645`) +- :meth:`TimedeltaIndex.searchsorted(), :meth:`DatetimeIndex.searchsorted()`, and :meth:`PeriodIndex.searchsorted()` have renamed the ``key`` argument to ``value`` (:issue:`14645`) .. _whatsnew_0240.performance: diff --git a/pandas/core/arrays/categorical.py b/pandas/core/arrays/categorical.py index 5410412d5f45b..63a1dacb47abb 100644 --- a/pandas/core/arrays/categorical.py +++ b/pandas/core/arrays/categorical.py @@ -1335,7 +1335,6 @@ def memory_usage(self, deep=False): @Substitution(klass='Categorical') @Appender(_shared_docs['searchsorted']) - @deprecate_kwarg(old_arg_name='v', new_arg_name='value') def searchsorted(self, value, side='left', sorter=None): if not self.ordered: raise ValueError("Categorical not ordered\nyou can use " diff --git a/pandas/core/base.py b/pandas/core/base.py index 084a976320d77..d831dc69338bd 100644 --- a/pandas/core/base.py +++ b/pandas/core/base.py @@ -24,8 +24,7 @@ import pandas._libs.lib as lib from pandas.compat.numpy import function as nv from pandas.compat import PYPY, OrderedDict -from pandas.util._decorators import (Appender, cache_readonly, - deprecate_kwarg, Substitution) +from pandas.util._decorators import Appender, cache_readonly, Substitution from pandas.core.accessor import DirNamesMixin @@ -1228,7 +1227,6 @@ def factorize(self, sort=False, na_sentinel=-1): @Substitution(klass='IndexOpsMixin') @Appender(_shared_docs['searchsorted']) - @deprecate_kwarg(old_arg_name='key', new_arg_name='value') def searchsorted(self, value, side='left', sorter=None): # needs coercion on the key (DatetimeIndex does already) return self.values.searchsorted(value, side=side, sorter=sorter) diff --git a/pandas/core/indexes/datetimes.py b/pandas/core/indexes/datetimes.py index f780b68a536a1..46741ab15aa31 100644 --- a/pandas/core/indexes/datetimes.py +++ b/pandas/core/indexes/datetimes.py @@ -43,8 +43,7 @@ generate_range, CDay, prefix_mapping) from pandas.core.tools.timedeltas import to_timedelta -from pandas.util._decorators import ( - Appender, cache_readonly, deprecate_kwarg, Substitution) +from pandas.util._decorators import Appender, cache_readonly, Substitution import pandas.core.common as com import pandas.tseries.offsets as offsets import pandas.core.tools.datetimes as tools @@ -1375,7 +1374,6 @@ def normalize(self): @Substitution(klass='DatetimeIndex') @Appender(_shared_docs['searchsorted']) - @deprecate_kwarg(old_arg_name='key', new_arg_name='value') def searchsorted(self, value, side='left', sorter=None): if isinstance(value, (np.ndarray, Index)): value = np.array(value, dtype=_NS_DTYPE, copy=False) diff --git a/pandas/core/indexes/period.py b/pandas/core/indexes/period.py index 3a68c6c26a974..0f86e18103e3c 100644 --- a/pandas/core/indexes/period.py +++ b/pandas/core/indexes/period.py @@ -36,8 +36,7 @@ from pandas.core.indexes.base import _index_shared_docs, ensure_index from pandas import compat -from pandas.util._decorators import (Appender, Substitution, cache_readonly, - deprecate_kwarg) +from pandas.util._decorators import Appender, Substitution, cache_readonly import pandas.core.indexes.base as ibase _index_doc_kwargs = dict(ibase._index_doc_kwargs) @@ -426,7 +425,6 @@ def astype(self, dtype, copy=True, how='start'): @Substitution(klass='PeriodIndex') @Appender(_shared_docs['searchsorted']) - @deprecate_kwarg(old_arg_name='key', new_arg_name='value') def searchsorted(self, value, side='left', sorter=None): if isinstance(value, Period): if value.freq != self.freq: diff --git a/pandas/core/indexes/timedeltas.py b/pandas/core/indexes/timedeltas.py index e0c78d6a1c518..933bc6233dca9 100644 --- a/pandas/core/indexes/timedeltas.py +++ b/pandas/core/indexes/timedeltas.py @@ -29,7 +29,7 @@ from pandas.core.indexes.base import _index_shared_docs import pandas.core.common as com import pandas.core.dtypes.concat as _concat -from pandas.util._decorators import Appender, Substitution, deprecate_kwarg +from pandas.util._decorators import Appender, Substitution from pandas.core.indexes.datetimelike import ( TimelikeOps, DatetimeIndexOpsMixin, wrap_arithmetic_op) from pandas.core.tools.timedeltas import ( @@ -609,7 +609,6 @@ def _partial_td_slice(self, key, freq, use_lhs=True, use_rhs=True): @Substitution(klass='TimedeltaIndex') @Appender(_shared_docs['searchsorted']) - @deprecate_kwarg(old_arg_name='key', new_arg_name='value') def searchsorted(self, value, side='left', sorter=None): if isinstance(value, (np.ndarray, Index)): value = np.array(value, dtype=_TD_DTYPE, copy=False) diff --git a/pandas/core/series.py b/pandas/core/series.py index ab41954990412..a4d403e4bcd94 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -75,8 +75,7 @@ import pandas.core.indexes.base as ibase import pandas.io.formats.format as fmt -from pandas.util._decorators import ( - Appender, deprecate, deprecate_kwarg, Substitution) +from pandas.util._decorators import Appender, deprecate, Substitution from pandas.util._validators import validate_bool_kwarg from pandas._libs import index as libindex, tslibs, lib, iNaT @@ -2089,7 +2088,6 @@ def __rmatmul__(self, other): @Substitution(klass='Series') @Appender(base._shared_docs['searchsorted']) - @deprecate_kwarg(old_arg_name='v', new_arg_name='value') def searchsorted(self, value, side='left', sorter=None): if sorter is not None: sorter = ensure_platform_int(sorter) diff --git a/pandas/tests/arrays/categorical/test_analytics.py b/pandas/tests/arrays/categorical/test_analytics.py index 53d0e596a1d99..b1b2e609f9b07 100644 --- a/pandas/tests/arrays/categorical/test_analytics.py +++ b/pandas/tests/arrays/categorical/test_analytics.py @@ -118,11 +118,6 @@ def test_searchsorted(self): pytest.raises(ValueError, lambda: c2.searchsorted('apple')) pytest.raises(ValueError, lambda: s2.searchsorted('apple')) - with tm.assert_produces_warning(FutureWarning): - res = c1.searchsorted(v=['bread']) - exp = np.array([3], dtype=np.intp) - tm.assert_numpy_array_equal(res, exp) - def test_unique(self): # categories are reordered based on value when ordered=False cat = Categorical(["a", "b"]) diff --git a/pandas/tests/indexes/period/test_tools.py b/pandas/tests/indexes/period/test_tools.py index c4ed07d98413f..a5c58eb40cc0d 100644 --- a/pandas/tests/indexes/period/test_tools.py +++ b/pandas/tests/indexes/period/test_tools.py @@ -220,9 +220,6 @@ def test_searchsorted(self, freq): with tm.assert_raises_regex(period.IncompatibleFrequency, msg): pidx.searchsorted(pd.Period('2014-01-01', freq='5D')) - with tm.assert_produces_warning(FutureWarning): - pidx.searchsorted(key=p2) - class TestPeriodIndexConversion(object): def test_tolist(self): diff --git a/pandas/tests/series/test_analytics.py b/pandas/tests/series/test_analytics.py index 3a8b84cd53087..d5d9e5f4f14de 100644 --- a/pandas/tests/series/test_analytics.py +++ b/pandas/tests/series/test_analytics.py @@ -1368,10 +1368,6 @@ def test_searchsorted(self): idx = s.searchsorted(1, side='right') tm.assert_numpy_array_equal(idx, np.array([1], dtype=np.intp)) - with tm.assert_produces_warning(FutureWarning): - idx = s.searchsorted(v=1, side='left') - tm.assert_numpy_array_equal(idx, np.array([0], dtype=np.intp)) - def test_searchsorted_numeric_dtypes_scalar(self): s = Series([1, 2, 90, 1000, 3e9]) r = s.searchsorted(30)