From 1d3a0794503bda1e1abb13e8a97a97f2c8861682 Mon Sep 17 00:00:00 2001 From: Brock Date: Wed, 23 Feb 2022 14:14:19 -0800 Subject: [PATCH 1/2] DEPR: non-keyword args in EA.argsort --- doc/source/whatsnew/v1.5.0.rst | 3 ++- pandas/core/arrays/base.py | 2 ++ pandas/core/arrays/categorical.py | 2 ++ pandas/core/arrays/interval.py | 6 +++++- 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/doc/source/whatsnew/v1.5.0.rst b/doc/source/whatsnew/v1.5.0.rst index 199a52f9d770f..0f91fd0ad49b0 100644 --- a/doc/source/whatsnew/v1.5.0.rst +++ b/doc/source/whatsnew/v1.5.0.rst @@ -243,7 +243,8 @@ Other Deprecations - Deprecated treating float-dtype data as wall-times when passed with a timezone to :class:`Series` or :class:`DatetimeIndex` (:issue:`45573`) - Deprecated the behavior of :meth:`Series.fillna` and :meth:`DataFrame.fillna` with ``timedelta64[ns]`` dtype and incompatible fill value; in a future version this will cast to a common dtype (usually object) instead of raising, matching the behavior of other dtypes (:issue:`45746`) - Deprecated the ``warn`` parameter in :func:`infer_freq` (:issue:`45947`) - +- Deprecated allowing non-keyword arguments in :meth:`ExtensionArray.argsort` (:issue:`??`) +- .. --------------------------------------------------------------------------- .. _whatsnew_150.performance: diff --git a/pandas/core/arrays/base.py b/pandas/core/arrays/base.py index 7c0daeecafaf7..b18a963e0cbc2 100644 --- a/pandas/core/arrays/base.py +++ b/pandas/core/arrays/base.py @@ -43,6 +43,7 @@ Appender, Substitution, cache_readonly, + deprecate_nonkeyword_arguments, ) from pandas.util._validators import ( validate_bool_kwarg, @@ -642,6 +643,7 @@ def _values_for_argsort(self) -> np.ndarray: # Note: this is used in `ExtensionArray.argsort/argmin/argmax`. return np.array(self) + @deprecate_nonkeyword_arguments(version=None, allowed_args=["self"]) def argsort( self, ascending: bool = True, diff --git a/pandas/core/arrays/categorical.py b/pandas/core/arrays/categorical.py index 3d9d3ef8a2557..db68eac504885 100644 --- a/pandas/core/arrays/categorical.py +++ b/pandas/core/arrays/categorical.py @@ -45,6 +45,7 @@ from pandas.util._decorators import ( cache_readonly, deprecate_kwarg, + deprecate_nonkeyword_arguments, ) from pandas.util._exceptions import find_stack_level from pandas.util._validators import validate_bool_kwarg @@ -1716,6 +1717,7 @@ def check_for_ordered(self, op): "Categorical to an ordered one\n" ) + @deprecate_nonkeyword_arguments(version=None, allowed_args=["self"]) def argsort(self, ascending=True, kind="quicksort", **kwargs): """ Return the indices that would sort the Categorical. diff --git a/pandas/core/arrays/interval.py b/pandas/core/arrays/interval.py index d23910c37b52b..2098dface40f6 100644 --- a/pandas/core/arrays/interval.py +++ b/pandas/core/arrays/interval.py @@ -37,7 +37,10 @@ ) from pandas.compat.numpy import function as nv from pandas.errors import IntCastingNaNError -from pandas.util._decorators import Appender +from pandas.util._decorators import ( + Appender, + deprecate_nonkeyword_arguments, +) from pandas.core.dtypes.cast import LossySetitemError from pandas.core.dtypes.common import ( @@ -776,6 +779,7 @@ def __lt__(self, other): def __le__(self, other): return self._cmp_method(other, operator.le) + @deprecate_nonkeyword_arguments(version=None, allowed_args=["self"]) def argsort( self, ascending: bool = True, From 985ac240efa97da3512a38d1561f852ea3ee4635 Mon Sep 17 00:00:00 2001 From: Brock Date: Wed, 23 Feb 2022 14:17:37 -0800 Subject: [PATCH 2/2] GH ref --- doc/source/whatsnew/v1.5.0.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v1.5.0.rst b/doc/source/whatsnew/v1.5.0.rst index 0f91fd0ad49b0..ade1fbcba0c26 100644 --- a/doc/source/whatsnew/v1.5.0.rst +++ b/doc/source/whatsnew/v1.5.0.rst @@ -243,7 +243,7 @@ Other Deprecations - Deprecated treating float-dtype data as wall-times when passed with a timezone to :class:`Series` or :class:`DatetimeIndex` (:issue:`45573`) - Deprecated the behavior of :meth:`Series.fillna` and :meth:`DataFrame.fillna` with ``timedelta64[ns]`` dtype and incompatible fill value; in a future version this will cast to a common dtype (usually object) instead of raising, matching the behavior of other dtypes (:issue:`45746`) - Deprecated the ``warn`` parameter in :func:`infer_freq` (:issue:`45947`) -- Deprecated allowing non-keyword arguments in :meth:`ExtensionArray.argsort` (:issue:`??`) +- Deprecated allowing non-keyword arguments in :meth:`ExtensionArray.argsort` (:issue:`46134`) - .. ---------------------------------------------------------------------------