diff --git a/doc/source/whatsnew/v1.5.0.rst b/doc/source/whatsnew/v1.5.0.rst index 199a52f9d770f..ade1fbcba0c26 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:`46134`) +- .. --------------------------------------------------------------------------- .. _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,