From 652525520062d435c4e1b28039e8431208222d02 Mon Sep 17 00:00:00 2001 From: Brock Date: Tue, 25 Oct 2022 07:38:12 -0700 Subject: [PATCH 1/2] DEPR: non-keyword arguments --- doc/source/whatsnew/v2.0.0.rst | 13 +++++++++++ pandas/core/frame.py | 23 +++++++++---------- pandas/core/generic.py | 17 +++++++++----- pandas/core/indexes/base.py | 8 +++---- pandas/core/indexes/multi.py | 7 ++---- pandas/core/reshape/concat.py | 12 ++++++---- pandas/core/reshape/pivot.py | 3 +-- pandas/core/series.py | 21 ++++++++--------- pandas/io/json/_json.py | 8 +++---- pandas/io/sas/sasreader.py | 9 ++++---- pandas/io/stata.py | 3 +-- pandas/io/xml.py | 7 ++---- pandas/tests/apply/test_frame_apply.py | 22 ------------------ .../frame/methods/test_drop_duplicates.py | 14 ----------- .../tests/frame/methods/test_interpolate.py | 12 ---------- pandas/tests/frame/methods/test_sort_index.py | 12 ---------- pandas/tests/indexes/multi/test_get_set.py | 17 -------------- pandas/tests/indexes/test_base.py | 13 ----------- .../tests/io/json/test_deprecated_kwargs.py | 13 ----------- pandas/tests/io/xml/test_xml.py | 13 ----------- pandas/tests/reshape/concat/test_concat.py | 15 ------------ pandas/tests/reshape/test_pivot.py | 6 ++--- .../tests/series/methods/test_interpolate.py | 12 ---------- .../tests/series/methods/test_sort_index.py | 12 ---------- 24 files changed, 71 insertions(+), 221 deletions(-) diff --git a/doc/source/whatsnew/v2.0.0.rst b/doc/source/whatsnew/v2.0.0.rst index a3b6d1dc90fee..cd4c615b0f73f 100644 --- a/doc/source/whatsnew/v2.0.0.rst +++ b/doc/source/whatsnew/v2.0.0.rst @@ -193,6 +193,19 @@ Removal of prior version deprecations/changes - Disallow passing non-round floats to :class:`Timestamp` with ``unit="M"`` or ``unit="Y"`` (:issue:`47266`) - Remove keywords ``convert_float`` and ``mangle_dupe_cols`` from :func:`read_excel` (:issue:`41176`) - Disallow passing non-keyword arguments to :func:`read_excel` except ``io`` and ``sheet_name`` (:issue:`34418`) +- Disallow passing non-keyword arguments to :meth:`DataFrame.drop_duplicates` except for ``subset`` (:issue:`41485`) +- Disallow passing non-keyword arguments to :meth:`DataFrame.sort_index` and :meth:`Series.sort_index` (:issue:`41506`) +- Disallow passing non-keyword arguments to :meth:`DataFrame.interpolate` and :meth:`Series.interpolate` except for ``method`` (:issue:`41510`) +- Disallow passing non-keyword arguments to :meth:`DataFrame.any` and :meth:`Series.any` (:issue:`44896`) +- Disallow passing non-keyword arguments to :meth:`Index.set_names` except for ``names`` (:issue:`41551`) +- Disallow passing non-keyword arguments to :meth:`Index.join` except for ``other`` (:issue:`46518`) +- Disallow passing non-keyword arguments to :func:`concat` except for ``objs`` (:issue:`41485`) +- Disallow passing non-keyword arguments to :func:`pivot` except for ``data`` (:issue:`48301`) +- Disallow passing non-keyword arguments to :meth:`DataFrame.pivot` (:issue:48301`) +- Disallow passing non-keyword arguments to :func:`read_json` except for ``path_or_buf`` (:issue:`27573`) +- Disallow passing non-keyword arguments to :func:`read_sas` except for ``filepath_or_buffer`` (:issue:`47154`) +- Disallow passing non-keyword arguments to :func:`read_stata` except for ``filepath_or_buffer`` (:issue:`48128`) +- Disallow passing non-keyword arguments to :func:`read_xml` except for ``path_or_buffer`` (:issue:`45133`) - Disallow passing non-keyword arguments to :meth:`Series.mask` and :meth:`DataFrame.mask` except ``cond`` and ``other`` (:issue:`41580`) - Disallow passing non-keyword arguments to :meth:`DataFrame.to_stata` except for ``path`` (:issue:`48128`) - Disallow passing non-keyword arguments to :meth:`DataFrame.where` and :meth:`Series.where` except for ``cond`` and ``other`` (:issue:`41523`) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index cc2bca1bcece6..84b8960965463 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -6556,10 +6556,10 @@ def dropna( self._update_inplace(result) return None - @deprecate_nonkeyword_arguments(version=None, allowed_args=["self", "subset"]) def drop_duplicates( self, subset: Hashable | Sequence[Hashable] | None = None, + *, keep: DropKeep = "first", inplace: bool = False, ignore_index: bool = False, @@ -6964,10 +6964,9 @@ def sort_index( ) -> DataFrame | None: ... - # error: Signature of "sort_index" incompatible with supertype "NDFrame" - @deprecate_nonkeyword_arguments(version=None, allowed_args=["self"]) - def sort_index( # type: ignore[override] + def sort_index( self, + *, axis: Axis = 0, level: IndexLabel = None, ascending: bool | Sequence[bool] = True, @@ -11794,10 +11793,10 @@ def clip( ) -> DataFrame | None: return super().clip(lower, upper, axis=axis, inplace=inplace, **kwargs) - @deprecate_nonkeyword_arguments(version=None, allowed_args=["self", "method"]) def interpolate( self: DataFrame, method: str = "linear", + *, axis: Axis = 0, limit: int | None = None, inplace: bool = False, @@ -11807,13 +11806,13 @@ def interpolate( **kwargs, ) -> DataFrame | None: return super().interpolate( - method, - axis, - limit, - inplace, - limit_direction, - limit_area, - downcast, + method=method, + axis=axis, + limit=limit, + inplace=inplace, + limit_direction=limit_direction, + limit_area=limit_area, + downcast=downcast, **kwargs, ) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index a1f799ec5122a..13a2a00dbc6eb 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -5000,6 +5000,7 @@ def sort_index( def sort_index( self: NDFrameT, + *, axis: Axis = 0, level: IndexLabel = None, ascending: bool_t | Sequence[bool_t] = True, @@ -7312,6 +7313,7 @@ def replace( def interpolate( self: NDFrameT, method: str = "linear", + *, axis: Axis = 0, limit: int | None = None, inplace: bool_t = False, @@ -11429,11 +11431,6 @@ def _add_numeric_operations(cls) -> None: """ axis_descr, name1, name2 = _doc_params(cls) - @deprecate_nonkeyword_arguments( - version=None, - allowed_args=["self"], - name="DataFrame.any and Series.any", - ) @doc( _bool_doc, desc=_any_desc, @@ -11446,13 +11443,21 @@ def _add_numeric_operations(cls) -> None: ) def any( self, + *, axis: Axis = 0, bool_only=None, skipna: bool_t = True, level=None, **kwargs, ): - return NDFrame.any(self, axis, bool_only, skipna, level, **kwargs) + return NDFrame.any( + self, + axis=axis, + bool_only=bool_only, + skipna=skipna, + level=level, + **kwargs, + ) setattr(cls, "any", any) diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index 1d3efe8bedd94..f7306142ef16f 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -223,7 +223,8 @@ def _maybe_return_indexers(meth: F) -> F: @functools.wraps(meth) def join( self, - other, + other: Index, + *, how: str_t = "left", level=None, return_indexers: bool = False, @@ -1803,9 +1804,8 @@ def set_names( ) -> _IndexT | None: ... - @deprecate_nonkeyword_arguments(version=None, allowed_args=["self", "names"]) def set_names( - self: _IndexT, names, level=None, inplace: bool = False + self: _IndexT, names, *, level=None, inplace: bool = False ) -> _IndexT | None: """ Set Index or MultiIndex name. @@ -4537,11 +4537,11 @@ def join( ... @final - @deprecate_nonkeyword_arguments(version=None, allowed_args=["self", "other"]) @_maybe_return_indexers def join( self, other: Index, + *, how: str_t = "left", level: Level = None, return_indexers: bool = False, diff --git a/pandas/core/indexes/multi.py b/pandas/core/indexes/multi.py index bb7a48946d4ca..27058cb54dddf 100644 --- a/pandas/core/indexes/multi.py +++ b/pandas/core/indexes/multi.py @@ -50,7 +50,6 @@ from pandas.util._decorators import ( Appender, cache_readonly, - deprecate_nonkeyword_arguments, doc, ) from pandas.util._exceptions import find_stack_level @@ -3786,10 +3785,8 @@ def set_names(self, names, *, level=..., inplace: Literal[True]) -> None: def set_names(self, names, *, level=..., inplace: bool = ...) -> MultiIndex | None: ... - # error: Signature of "set_names" incompatible with supertype "Index" - @deprecate_nonkeyword_arguments(version=None, allowed_args=["self", "names"]) - def set_names( # type: ignore[override] - self, names, level=None, inplace: bool = False + def set_names( + self, names, *, level=None, inplace: bool = False ) -> MultiIndex | None: return super().set_names(names=names, level=level, inplace=inplace) diff --git a/pandas/core/reshape/concat.py b/pandas/core/reshape/concat.py index e8fd8ed737fd6..31b6209855561 100644 --- a/pandas/core/reshape/concat.py +++ b/pandas/core/reshape/concat.py @@ -23,10 +23,7 @@ AxisInt, HashableT, ) -from pandas.util._decorators import ( - cache_readonly, - deprecate_nonkeyword_arguments, -) +from pandas.util._decorators import cache_readonly from pandas.util._exceptions import find_stack_level from pandas.core.dtypes.concat import concat_compat @@ -67,6 +64,7 @@ @overload def concat( objs: Iterable[DataFrame] | Mapping[HashableT, DataFrame], + *, axis: Literal[0, "index"] = ..., join: str = ..., ignore_index: bool = ..., @@ -83,6 +81,7 @@ def concat( @overload def concat( objs: Iterable[Series] | Mapping[HashableT, Series], + *, axis: Literal[0, "index"] = ..., join: str = ..., ignore_index: bool = ..., @@ -99,6 +98,7 @@ def concat( @overload def concat( objs: Iterable[NDFrame] | Mapping[HashableT, NDFrame], + *, axis: Literal[0, "index"] = ..., join: str = ..., ignore_index: bool = ..., @@ -115,6 +115,7 @@ def concat( @overload def concat( objs: Iterable[NDFrame] | Mapping[HashableT, NDFrame], + *, axis: Literal[1, "columns"], join: str = ..., ignore_index: bool = ..., @@ -131,6 +132,7 @@ def concat( @overload def concat( objs: Iterable[NDFrame] | Mapping[HashableT, NDFrame], + *, axis: Axis = ..., join: str = ..., ignore_index: bool = ..., @@ -144,9 +146,9 @@ def concat( ... -@deprecate_nonkeyword_arguments(version=None, allowed_args=["objs"]) def concat( objs: Iterable[NDFrame] | Mapping[HashableT, NDFrame], + *, axis: Axis = 0, join: str = "outer", ignore_index: bool = False, diff --git a/pandas/core/reshape/pivot.py b/pandas/core/reshape/pivot.py index 51ca0e90f8809..8b49d681379c6 100644 --- a/pandas/core/reshape/pivot.py +++ b/pandas/core/reshape/pivot.py @@ -20,7 +20,6 @@ from pandas.util._decorators import ( Appender, Substitution, - deprecate_nonkeyword_arguments, ) from pandas.core.dtypes.cast import maybe_downcast_to_dtype @@ -493,9 +492,9 @@ def _convert_by(by): @Substitution("\ndata : DataFrame") @Appender(_shared_docs["pivot"], indents=1) -@deprecate_nonkeyword_arguments(version=None, allowed_args=["data"]) def pivot( data: DataFrame, + *, index: IndexLabel | lib.NoDefault = lib.NoDefault, columns: IndexLabel | lib.NoDefault = lib.NoDefault, values: IndexLabel | lib.NoDefault = lib.NoDefault, diff --git a/pandas/core/series.py b/pandas/core/series.py index 2987858492a25..7d6932457ac29 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -3767,10 +3767,9 @@ def sort_index( ) -> Series | None: ... - # error: Signature of "sort_index" incompatible with supertype "NDFrame" - @deprecate_nonkeyword_arguments(version=None, allowed_args=["self"]) - def sort_index( # type: ignore[override] + def sort_index( self, + *, axis: Axis = 0, level: IndexLabel = None, ascending: bool | Sequence[bool] = True, @@ -5993,10 +5992,10 @@ def clip( ) -> Series | None: return super().clip(lower, upper, axis=axis, inplace=inplace, **kwargs) - @deprecate_nonkeyword_arguments(version=None, allowed_args=["self", "method"]) def interpolate( self: Series, method: str = "linear", + *, axis: Axis = 0, limit: int | None = None, inplace: bool = False, @@ -6006,13 +6005,13 @@ def interpolate( **kwargs, ) -> Series | None: return super().interpolate( - method, - axis, - limit, - inplace, - limit_direction, - limit_area, - downcast, + method=method, + axis=axis, + limit=limit, + inplace=inplace, + limit_direction=limit_direction, + limit_area=limit_area, + downcast=downcast, **kwargs, ) diff --git a/pandas/io/json/_json.py b/pandas/io/json/_json.py index 4bf883a7214bf..15e7da1b8525e 100644 --- a/pandas/io/json/_json.py +++ b/pandas/io/json/_json.py @@ -34,10 +34,7 @@ WriteBuffer, ) from pandas.errors import AbstractMethodError -from pandas.util._decorators import ( - deprecate_nonkeyword_arguments, - doc, -) +from pandas.util._decorators import doc from pandas.core.dtypes.common import ( ensure_str, @@ -452,6 +449,7 @@ def read_json( @overload def read_json( path_or_buf: FilePath | ReadBuffer[str] | ReadBuffer[bytes], + *, orient: str | None = ..., typ: Literal["frame"] = ..., dtype: DtypeArg | None = ..., @@ -475,9 +473,9 @@ def read_json( storage_options=_shared_docs["storage_options"], decompression_options=_shared_docs["decompression_options"] % "path_or_buf", ) -@deprecate_nonkeyword_arguments(version="2.0", allowed_args=["path_or_buf"]) def read_json( path_or_buf: FilePath | ReadBuffer[str] | ReadBuffer[bytes], + *, orient: str | None = None, typ: Literal["frame", "series"] = "frame", dtype: DtypeArg | None = None, diff --git a/pandas/io/sas/sasreader.py b/pandas/io/sas/sasreader.py index 2b6472913a4d3..bcd342ddb9023 100644 --- a/pandas/io/sas/sasreader.py +++ b/pandas/io/sas/sasreader.py @@ -19,10 +19,7 @@ FilePath, ReadBuffer, ) -from pandas.util._decorators import ( - deprecate_nonkeyword_arguments, - doc, -) +from pandas.util._decorators import doc from pandas.core.shared_docs import _shared_docs @@ -61,6 +58,7 @@ def __exit__( @overload def read_sas( filepath_or_buffer: FilePath | ReadBuffer[bytes], + *, format: str | None = ..., index: Hashable | None = ..., encoding: str | None = ..., @@ -74,6 +72,7 @@ def read_sas( @overload def read_sas( filepath_or_buffer: FilePath | ReadBuffer[bytes], + *, format: str | None = ..., index: Hashable | None = ..., encoding: str | None = ..., @@ -84,10 +83,10 @@ def read_sas( ... -@deprecate_nonkeyword_arguments(version=None, allowed_args=["filepath_or_buffer"]) @doc(decompression_options=_shared_docs["decompression_options"] % "filepath_or_buffer") def read_sas( filepath_or_buffer: FilePath | ReadBuffer[bytes], + *, format: str | None = None, index: Hashable | None = None, encoding: str | None = None, diff --git a/pandas/io/stata.py b/pandas/io/stata.py index 5e9b70aeb2a82..60c710d1930ed 100644 --- a/pandas/io/stata.py +++ b/pandas/io/stata.py @@ -50,7 +50,6 @@ ) from pandas.util._decorators import ( Appender, - deprecate_nonkeyword_arguments, doc, ) from pandas.util._exceptions import find_stack_level @@ -2009,9 +2008,9 @@ def value_labels(self) -> dict[str, dict[float, str]]: @Appender(_read_stata_doc) -@deprecate_nonkeyword_arguments(version=None, allowed_args=["filepath_or_buffer"]) def read_stata( filepath_or_buffer: FilePath | ReadBuffer[bytes], + *, convert_dates: bool = True, convert_categoricals: bool = True, index_col: str | None = None, diff --git a/pandas/io/xml.py b/pandas/io/xml.py index 71d19b7861fc2..f042494d0c9ca 100644 --- a/pandas/io/xml.py +++ b/pandas/io/xml.py @@ -27,10 +27,7 @@ AbstractMethodError, ParserError, ) -from pandas.util._decorators import ( - deprecate_nonkeyword_arguments, - doc, -) +from pandas.util._decorators import doc from pandas.core.dtypes.common import is_list_like @@ -853,13 +850,13 @@ def _parse( ) -@deprecate_nonkeyword_arguments(version=None, allowed_args=["path_or_buffer"]) @doc( storage_options=_shared_docs["storage_options"], decompression_options=_shared_docs["decompression_options"] % "path_or_buffer", ) def read_xml( path_or_buffer: FilePath | ReadBuffer[bytes] | ReadBuffer[str], + *, xpath: str = "./*", namespaces: dict[str, str] | None = None, elems_only: bool = False, diff --git a/pandas/tests/apply/test_frame_apply.py b/pandas/tests/apply/test_frame_apply.py index a7aefc9b1eaa0..c6294cfc0c670 100644 --- a/pandas/tests/apply/test_frame_apply.py +++ b/pandas/tests/apply/test_frame_apply.py @@ -1606,28 +1606,6 @@ def test_unique_agg_type_is_series(test, constant): tm.assert_series_equal(result, expected) -def test_any_non_keyword_deprecation(): - df = DataFrame({"A": [1, 2], "B": [0, 2], "C": [0, 0]}) - msg = ( - "In a future version of pandas all arguments of " - "DataFrame.any and Series.any will be keyword-only." - ) - with tm.assert_produces_warning(FutureWarning, match=msg): - result = df.any("index", None) - expected = Series({"A": True, "B": True, "C": False}) - tm.assert_series_equal(result, expected) - - s = Series([False, False, False]) - msg = ( - "In a future version of pandas all arguments of " - "DataFrame.any and Series.any will be keyword-only." - ) - with tm.assert_produces_warning(FutureWarning, match=msg): - result = s.any("index") - expected = False - tm.assert_equal(result, expected) - - def test_any_apply_keyword_non_zero_axis_regression(): # https://github.com/pandas-dev/pandas/issues/48656 df = DataFrame({"A": [1, 2, 0], "B": [0, 2, 0], "C": [0, 0, 0]}) diff --git a/pandas/tests/frame/methods/test_drop_duplicates.py b/pandas/tests/frame/methods/test_drop_duplicates.py index cd61f59a85d1e..988d8e3b6f13f 100644 --- a/pandas/tests/frame/methods/test_drop_duplicates.py +++ b/pandas/tests/frame/methods/test_drop_duplicates.py @@ -472,17 +472,3 @@ def test_drop_duplicates_non_boolean_ignore_index(arg): msg = '^For argument "ignore_index" expected type bool, received type .*.$' with pytest.raises(ValueError, match=msg): df.drop_duplicates(ignore_index=arg) - - -def test_drop_duplicates_pos_args_deprecation(): - # GH#41485 - df = DataFrame({"a": [1, 1, 2], "b": [1, 1, 3], "c": [1, 1, 3]}) - msg = ( - "In a future version of pandas all arguments of " - "DataFrame.drop_duplicates except for the argument 'subset' " - "will be keyword-only" - ) - with tm.assert_produces_warning(FutureWarning, match=msg): - result = df.drop_duplicates(["b", "c"], "last") - expected = DataFrame({"a": [1, 2], "b": [1, 3], "c": [1, 3]}, index=[1, 2]) - tm.assert_frame_equal(expected, result) diff --git a/pandas/tests/frame/methods/test_interpolate.py b/pandas/tests/frame/methods/test_interpolate.py index 6543fd8efdf1b..00fdfe373f1d8 100644 --- a/pandas/tests/frame/methods/test_interpolate.py +++ b/pandas/tests/frame/methods/test_interpolate.py @@ -397,15 +397,3 @@ def test_interp_fillna_methods(self, request, axis, method, using_array_manager) expected = df.fillna(axis=axis, method=method) result = df.interpolate(method=method, axis=axis) tm.assert_frame_equal(result, expected) - - def test_interpolate_pos_args_deprecation(self): - # https://github.com/pandas-dev/pandas/issues/41485 - df = DataFrame({"a": [1, 2, 3]}) - msg = ( - r"In a future version of pandas all arguments of DataFrame.interpolate " - r"except for the argument 'method' will be keyword-only" - ) - with tm.assert_produces_warning(FutureWarning, match=msg): - result = df.interpolate("pad", 0) - expected = DataFrame({"a": [1, 2, 3]}) - tm.assert_frame_equal(result, expected) diff --git a/pandas/tests/frame/methods/test_sort_index.py b/pandas/tests/frame/methods/test_sort_index.py index 5d1cc3d4ecee5..806abc1e7c012 100644 --- a/pandas/tests/frame/methods/test_sort_index.py +++ b/pandas/tests/frame/methods/test_sort_index.py @@ -913,15 +913,3 @@ def test_sort_index_multiindex_sparse_column(self): result = expected.sort_index(level=0) tm.assert_frame_equal(result, expected) - - def test_sort_index_pos_args_deprecation(self): - # https://github.com/pandas-dev/pandas/issues/41485 - df = DataFrame({"a": [1, 2, 3]}) - msg = ( - r"In a future version of pandas all arguments of DataFrame.sort_index " - r"will be keyword-only" - ) - with tm.assert_produces_warning(FutureWarning, match=msg): - result = df.sort_index(1) - expected = DataFrame({"a": [1, 2, 3]}) - tm.assert_frame_equal(result, expected) diff --git a/pandas/tests/indexes/multi/test_get_set.py b/pandas/tests/indexes/multi/test_get_set.py index 4fff4ca961cf7..70350f0df821b 100644 --- a/pandas/tests/indexes/multi/test_get_set.py +++ b/pandas/tests/indexes/multi/test_get_set.py @@ -299,23 +299,6 @@ def test_set_names_with_nlevel_1(inplace): tm.assert_index_equal(result, expected) -def test_multi_set_names_pos_args_deprecation(): - # GH#41485 - idx = MultiIndex.from_product([["python", "cobra"], [2018, 2019]]) - msg = ( - "In a future version of pandas all arguments of MultiIndex.set_names " - "except for the argument 'names' will be keyword-only" - ) - with tm.assert_produces_warning(FutureWarning, match=msg): - result = idx.set_names(["kind", "year"], None) - expected = MultiIndex( - levels=[["python", "cobra"], [2018, 2019]], - codes=[[0, 0, 1, 1], [0, 1, 0, 1]], - names=["kind", "year"], - ) - tm.assert_index_equal(result, expected) - - @pytest.mark.parametrize("ordered", [True, False]) def test_set_levels_categorical(ordered): # GH13854 diff --git a/pandas/tests/indexes/test_base.py b/pandas/tests/indexes/test_base.py index bfe462cdf6c15..d761695bca61d 100644 --- a/pandas/tests/indexes/test_base.py +++ b/pandas/tests/indexes/test_base.py @@ -1582,19 +1582,6 @@ def test_construct_from_memoryview(klass, extra_kwargs): tm.assert_index_equal(result, expected, exact=True) -def test_index_set_names_pos_args_deprecation(): - # GH#41485 - idx = Index([1, 2, 3, 4]) - msg = ( - "In a future version of pandas all arguments of Index.set_names " - "except for the argument 'names' will be keyword-only" - ) - with tm.assert_produces_warning(FutureWarning, match=msg): - result = idx.set_names("quarter", None) - expected = Index([1, 2, 3, 4], name="quarter") - tm.assert_index_equal(result, expected) - - def test_drop_duplicates_pos_args_deprecation(): # GH#41485 idx = Index([1, 2, 3, 1]) diff --git a/pandas/tests/io/json/test_deprecated_kwargs.py b/pandas/tests/io/json/test_deprecated_kwargs.py index 79245bc9d34a8..7e3296db75323 100644 --- a/pandas/tests/io/json/test_deprecated_kwargs.py +++ b/pandas/tests/io/json/test_deprecated_kwargs.py @@ -8,19 +8,6 @@ from pandas.io.json import read_json -def test_deprecated_kwargs(): - df = pd.DataFrame({"A": [2, 4, 6], "B": [3, 6, 9]}, index=[0, 1, 2]) - buf = df.to_json(orient="split") - with tm.assert_produces_warning(FutureWarning): - tm.assert_frame_equal(df, read_json(buf, "split")) - buf = df.to_json(orient="columns") - with tm.assert_produces_warning(FutureWarning): - tm.assert_frame_equal(df, read_json(buf, "columns")) - buf = df.to_json(orient="index") - with tm.assert_produces_warning(FutureWarning): - tm.assert_frame_equal(df, read_json(buf, "index")) - - def test_good_kwargs(): df = pd.DataFrame({"A": [2, 4, 6], "B": [3, 6, 9]}, index=[0, 1, 2]) with tm.assert_produces_warning(None): diff --git a/pandas/tests/io/xml/test_xml.py b/pandas/tests/io/xml/test_xml.py index baebc562fc5ff..0829ece64c451 100644 --- a/pandas/tests/io/xml/test_xml.py +++ b/pandas/tests/io/xml/test_xml.py @@ -1096,19 +1096,6 @@ def test_stylesheet_file(datapath): tm.assert_frame_equal(df_kml, df_iter) -def test_read_xml_passing_as_positional_deprecated(datapath, parser): - # GH#45133 - kml = datapath("io", "data", "xml", "cta_rail_lines.kml") - - with tm.assert_produces_warning(FutureWarning, match="keyword-only"): - read_xml( - kml, - ".//k:Placemark", - namespaces={"k": "http://www.opengis.net/kml/2.2"}, - parser=parser, - ) - - @td.skip_if_no("lxml") def test_stylesheet_file_like(datapath, mode): kml = datapath("io", "data", "xml", "cta_rail_lines.kml") diff --git a/pandas/tests/reshape/concat/test_concat.py b/pandas/tests/reshape/concat/test_concat.py index 277496d776cb2..d15199e84f7ac 100644 --- a/pandas/tests/reshape/concat/test_concat.py +++ b/pandas/tests/reshape/concat/test_concat.py @@ -697,21 +697,6 @@ def test_concat_multiindex_with_empty_rangeindex(): tm.assert_frame_equal(result, expected) -def test_concat_posargs_deprecation(): - # https://github.com/pandas-dev/pandas/issues/41485 - df = DataFrame([[1, 2, 3]], index=["a"]) - df2 = DataFrame([[4, 5, 6]], index=["b"]) - - msg = ( - "In a future version of pandas all arguments of concat " - "except for the argument 'objs' will be keyword-only" - ) - with tm.assert_produces_warning(FutureWarning, match=msg): - result = concat([df, df2], 0) - expected = DataFrame([[1, 2, 3], [4, 5, 6]], index=["a", "b"]) - tm.assert_frame_equal(result, expected) - - @pytest.mark.parametrize( "data", [ diff --git a/pandas/tests/reshape/test_pivot.py b/pandas/tests/reshape/test_pivot.py index 8c2c1026d5c82..464eca412daed 100644 --- a/pandas/tests/reshape/test_pivot.py +++ b/pandas/tests/reshape/test_pivot.py @@ -481,11 +481,9 @@ def test_pivot_index_with_nan(self, method): } ) if method: - with tm.assert_produces_warning(FutureWarning): - result = df.pivot("a", columns="b", values="c") + result = df.pivot(index="a", columns="b", values="c") else: - with tm.assert_produces_warning(FutureWarning): - result = pd.pivot(df, "a", columns="b", values="c") + result = pd.pivot(df, index="a", columns="b", values="c") expected = DataFrame( [ [nan, nan, 17, nan], diff --git a/pandas/tests/series/methods/test_interpolate.py b/pandas/tests/series/methods/test_interpolate.py index c46f427fd6f09..fc2f636199493 100644 --- a/pandas/tests/series/methods/test_interpolate.py +++ b/pandas/tests/series/methods/test_interpolate.py @@ -811,15 +811,3 @@ def test_interpolate_unsorted_index(self, ascending, expected_values): result = ts.sort_index(ascending=ascending).interpolate(method="index") expected = Series(data=expected_values, index=expected_values, dtype=float) tm.assert_series_equal(result, expected) - - def test_interpolate_pos_args_deprecation(self): - # https://github.com/pandas-dev/pandas/issues/41485 - ser = Series([1, 2, 3]) - msg = ( - r"In a future version of pandas all arguments of Series.interpolate except " - r"for the argument 'method' will be keyword-only" - ) - with tm.assert_produces_warning(FutureWarning, match=msg): - result = ser.interpolate("pad", 0) - expected = Series([1, 2, 3]) - tm.assert_series_equal(result, expected) diff --git a/pandas/tests/series/methods/test_sort_index.py b/pandas/tests/series/methods/test_sort_index.py index d7bd92c673e69..4df6f52e0fff4 100644 --- a/pandas/tests/series/methods/test_sort_index.py +++ b/pandas/tests/series/methods/test_sort_index.py @@ -320,15 +320,3 @@ def test_sort_values_key_type(self): result = s.sort_index(key=lambda x: x.month_name()) expected = s.iloc[[2, 1, 0]] tm.assert_series_equal(result, expected) - - def test_sort_index_pos_args_deprecation(self): - # https://github.com/pandas-dev/pandas/issues/41485 - ser = Series([1, 2, 3]) - msg = ( - r"In a future version of pandas all arguments of Series.sort_index " - r"will be keyword-only" - ) - with tm.assert_produces_warning(FutureWarning, match=msg): - result = ser.sort_index(0) - expected = Series([1, 2, 3]) - tm.assert_series_equal(result, expected) From 1d9fdf1153685a4af116475177d07ce26ba8ff9f Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Tue, 25 Oct 2022 11:32:05 -0700 Subject: [PATCH 2/2] Update doc/source/whatsnew/v2.0.0.rst Co-authored-by: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> --- doc/source/whatsnew/v2.0.0.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v2.0.0.rst b/doc/source/whatsnew/v2.0.0.rst index cd4c615b0f73f..d3eabe8fd7eb7 100644 --- a/doc/source/whatsnew/v2.0.0.rst +++ b/doc/source/whatsnew/v2.0.0.rst @@ -201,7 +201,7 @@ Removal of prior version deprecations/changes - Disallow passing non-keyword arguments to :meth:`Index.join` except for ``other`` (:issue:`46518`) - Disallow passing non-keyword arguments to :func:`concat` except for ``objs`` (:issue:`41485`) - Disallow passing non-keyword arguments to :func:`pivot` except for ``data`` (:issue:`48301`) -- Disallow passing non-keyword arguments to :meth:`DataFrame.pivot` (:issue:48301`) +- Disallow passing non-keyword arguments to :meth:`DataFrame.pivot` (:issue:`48301`) - Disallow passing non-keyword arguments to :func:`read_json` except for ``path_or_buf`` (:issue:`27573`) - Disallow passing non-keyword arguments to :func:`read_sas` except for ``filepath_or_buffer`` (:issue:`47154`) - Disallow passing non-keyword arguments to :func:`read_stata` except for ``filepath_or_buffer`` (:issue:`48128`)