diff --git a/doc/source/whatsnew/v3.0.0.rst b/doc/source/whatsnew/v3.0.0.rst index e07ee3cbe2867..58292ae0ee4de 100644 --- a/doc/source/whatsnew/v3.0.0.rst +++ b/doc/source/whatsnew/v3.0.0.rst @@ -105,7 +105,10 @@ Deprecations Removal of prior version deprecations/changes ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - :func:`read_excel`, :func:`read_json`, :func:`read_html`, and :func:`read_xml` no longer accept raw string or byte representation of the data. That type of data must be wrapped in a :py:class:`StringIO` or :py:class:`BytesIO` (:issue:`53767`) +- All arguments except ``name`` in :meth:`Index.rename` are now keyword only (:issue:`56493`) - All arguments except the first ``path``-like argument in IO writers are now keyword only (:issue:`54229`) +- All arguments in :meth:`Index.sort_values` are now keyword only (:issue:`56493`) +- All arguments in :meth:`Series.to_dict` are now keyword only (:issue:`56493`) - Changed the default value of ``observed`` in :meth:`DataFrame.groupby` and :meth:`Series.groupby` to ``True`` (:issue:`51811`) - Enforced silent-downcasting deprecation for :ref:`all relevant methods ` (:issue:`54710`) - Removed ``DataFrame.applymap``, ``Styler.applymap`` and ``Styler.applymap_index`` (:issue:`52364`) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 76c5549fc8f86..06b38fff57198 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -63,7 +63,6 @@ from pandas.util._decorators import ( Appender, Substitution, - deprecate_nonkeyword_arguments, doc, ) from pandas.util._exceptions import ( @@ -3195,9 +3194,6 @@ def to_xml( ) -> None: ... - @deprecate_nonkeyword_arguments( - version="3.0", allowed_args=["self", "path_or_buffer"], name="to_xml" - ) @doc( storage_options=_shared_docs["storage_options"], compression_options=_shared_docs["compression_options"] % "path_or_buffer", @@ -3205,6 +3201,7 @@ def to_xml( def to_xml( self, path_or_buffer: FilePath | WriteBuffer[bytes] | WriteBuffer[str] | None = None, + *, index: bool = True, root_name: str | None = "data", row_name: str | None = "row", diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index d9f545969d9f7..96f52cb5be3c0 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -71,7 +71,6 @@ from pandas.util._decorators import ( Appender, cache_readonly, - deprecate_nonkeyword_arguments, doc, ) from pandas.util._exceptions import ( @@ -1891,10 +1890,7 @@ def rename(self, name, *, inplace: Literal[False] = ...) -> Self: def rename(self, name, *, inplace: Literal[True]) -> None: ... - @deprecate_nonkeyword_arguments( - version="3.0", allowed_args=["self", "name"], name="rename" - ) - def rename(self, name, inplace: bool = False) -> Self | None: + def rename(self, name, *, inplace: bool = False) -> Self | None: """ Alter Index or MultiIndex name. @@ -5503,11 +5499,9 @@ def sort_values( ) -> Self | tuple[Self, np.ndarray]: ... - @deprecate_nonkeyword_arguments( - version="3.0", allowed_args=["self"], name="sort_values" - ) def sort_values( self, + *, return_indexer: bool = False, ascending: bool = True, na_position: NaPosition = "last", diff --git a/pandas/core/indexes/range.py b/pandas/core/indexes/range.py index 597832e51d122..a8e8ae140041a 100644 --- a/pandas/core/indexes/range.py +++ b/pandas/core/indexes/range.py @@ -27,7 +27,6 @@ from pandas.compat.numpy import function as nv from pandas.util._decorators import ( cache_readonly, - deprecate_nonkeyword_arguments, doc, ) @@ -592,11 +591,9 @@ def sort_values( ) -> Self | tuple[Self, np.ndarray | RangeIndex]: ... - @deprecate_nonkeyword_arguments( - version="3.0", allowed_args=["self"], name="sort_values" - ) def sort_values( self, + *, return_indexer: bool = False, ascending: bool = True, na_position: NaPosition = "last", diff --git a/pandas/core/series.py b/pandas/core/series.py index de76c05ef7943..1672c29f15763 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -46,7 +46,6 @@ from pandas.util._decorators import ( Appender, Substitution, - deprecate_nonkeyword_arguments, doc, ) from pandas.util._exceptions import find_stack_level @@ -1736,11 +1735,9 @@ def to_dict(self, *, into: type[dict] = ...) -> dict: # error: Incompatible default for argument "into" (default has type "type[ # dict[Any, Any]]", argument has type "type[MutableMappingT] | MutableMappingT") - @deprecate_nonkeyword_arguments( - version="3.0", allowed_args=["self"], name="to_dict" - ) def to_dict( self, + *, into: type[MutableMappingT] | MutableMappingT = dict, # type: ignore[assignment] ) -> MutableMappingT: """