From 862137a3aeaa99515147d634828fbf35b5704e5a Mon Sep 17 00:00:00 2001 From: Brock Date: Thu, 27 Oct 2022 13:31:01 -0700 Subject: [PATCH 1/2] DEPR: non-keyword arguments --- doc/source/whatsnew/v2.0.0.rst | 10 +++++++ pandas/core/arrays/arrow/array.py | 8 ++---- pandas/core/arrays/base.py | 6 ++--- pandas/core/arrays/categorical.py | 13 ++++----- pandas/core/arrays/interval.py | 10 +++---- pandas/core/base.py | 2 +- pandas/core/frame.py | 9 +++---- pandas/core/indexes/base.py | 4 +-- pandas/core/resample.py | 3 +-- pandas/core/series.py | 13 +++++---- pandas/io/parsers/readers.py | 7 +++-- pandas/tests/frame/methods/test_drop.py | 12 --------- pandas/tests/frame/methods/test_dropna.py | 12 --------- .../tests/frame/methods/test_reset_index.py | 13 --------- pandas/tests/frame/methods/test_set_index.py | 12 --------- pandas/tests/indexes/multi/test_duplicates.py | 13 --------- pandas/tests/indexes/test_base.py | 14 ---------- .../io/parser/common/test_common_basic.py | 22 --------------- pandas/tests/io/parser/test_read_fwf.py | 12 --------- pandas/tests/resample/test_deprecated.py | 27 ------------------- .../series/methods/test_drop_duplicates.py | 13 --------- pandas/tests/series/methods/test_dropna.py | 12 --------- .../tests/series/methods/test_reset_index.py | 12 --------- 23 files changed, 40 insertions(+), 219 deletions(-) diff --git a/doc/source/whatsnew/v2.0.0.rst b/doc/source/whatsnew/v2.0.0.rst index 252c444b2e60c..2cb77c14c1082 100644 --- a/doc/source/whatsnew/v2.0.0.rst +++ b/doc/source/whatsnew/v2.0.0.rst @@ -197,6 +197,13 @@ 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.set_index` except ``keys`` (:issue:`41495`) +- Disallow passing non-keyword arguments to :meth:`Resampler.interpolate` except ``method`` (:issue:`41699`) +- Disallow passing non-keyword arguments to :meth:`DataFrame.reset_index` and :meth:`Series.reset_index` except ``level`` (:issue:`41496`) +- Disallow passing non-keyword arguments to :meth:`DataFrame.dropna` and :meth:`Series.dropna` (:issue:`41504`) +- Disallow passing non-keyword arguments to :meth:`ExtensionArray.argsort` (:issue:`46134`) +- Disallow passing non-keyword arguments to :meth:`Categorical.sort_values` (:issue:`47618`) +- Disallow passing non-keyword arguments to :meth:`Index.drop_duplicates` and :meth:`Series.drop_duplicates` (:issue:`41485`) - 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`) @@ -209,6 +216,9 @@ Removal of prior version deprecations/changes - 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_csv` except ``filepath_or_buffer`` (:issue:`41485`) +- Disallow passing non-keyword arguments to :func:`read_table` except ``filepath_or_buffer`` (:issue:`41485`) +- Disallow passing non-keyword arguments to :func:`read_fwf` except ``filepath_or_buffer`` (:issue:`44710`) - 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`) diff --git a/pandas/core/arrays/arrow/array.py b/pandas/core/arrays/arrow/array.py index f18664915d015..945ae52c53047 100644 --- a/pandas/core/arrays/arrow/array.py +++ b/pandas/core/arrays/arrow/array.py @@ -20,10 +20,7 @@ pa_version_under6p0, pa_version_under7p0, ) -from pandas.util._decorators import ( - deprecate_nonkeyword_arguments, - doc, -) +from pandas.util._decorators import doc from pandas.core.dtypes.common import ( is_array_like, @@ -452,13 +449,12 @@ def isna(self) -> npt.NDArray[np.bool_]: """ return self._data.is_null().to_numpy() - @deprecate_nonkeyword_arguments(version=None, allowed_args=["self"]) def argsort( self, + *, ascending: bool = True, kind: SortKind = "quicksort", na_position: str = "last", - *args, **kwargs, ) -> np.ndarray: order = "ascending" if ascending else "descending" diff --git a/pandas/core/arrays/base.py b/pandas/core/arrays/base.py index 9758ca84d236b..60772cbcc30a1 100644 --- a/pandas/core/arrays/base.py +++ b/pandas/core/arrays/base.py @@ -48,7 +48,6 @@ Appender, Substitution, cache_readonly, - deprecate_nonkeyword_arguments, ) from pandas.util._exceptions import find_stack_level from pandas.util._validators import ( @@ -662,13 +661,12 @@ 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, kind: SortKind = "quicksort", na_position: str = "last", - *args, **kwargs, ) -> np.ndarray: """ @@ -699,7 +697,7 @@ def argsort( # 1. _values_for_argsort : construct the values passed to np.argsort # 2. argsort : total control over sorting. In case of overriding this, # it is recommended to also override argmax/argmin - ascending = nv.validate_argsort_with_ascending(ascending, args, kwargs) + ascending = nv.validate_argsort_with_ascending(ascending, (), kwargs) values = self._values_for_argsort() return nargsort( diff --git a/pandas/core/arrays/categorical.py b/pandas/core/arrays/categorical.py index 980e8b4936c4e..2d4c5808d3132 100644 --- a/pandas/core/arrays/categorical.py +++ b/pandas/core/arrays/categorical.py @@ -1802,10 +1802,8 @@ def check_for_ordered(self, op) -> None: "Categorical to an ordered one\n" ) - # error: Signature of "argsort" incompatible with supertype "ExtensionArray" - @deprecate_nonkeyword_arguments(version=None, allowed_args=["self"]) - def argsort( # type: ignore[override] - self, ascending: bool = True, kind: SortKind = "quicksort", **kwargs + def argsort( + self, *, ascending: bool = True, kind: SortKind = "quicksort", **kwargs ): """ Return the indices that would sort the Categorical. @@ -1875,9 +1873,12 @@ def sort_values( ) -> None: ... - @deprecate_nonkeyword_arguments(version=None, allowed_args=["self"]) def sort_values( - self, inplace: bool = False, ascending: bool = True, na_position: str = "last" + self, + *, + inplace: bool = False, + ascending: bool = True, + na_position: str = "last", ) -> Categorical | None: """ Sort the Categorical by category value returning a new diff --git a/pandas/core/arrays/interval.py b/pandas/core/arrays/interval.py index 2c15a7bbc88a7..2bc6c9174af81 100644 --- a/pandas/core/arrays/interval.py +++ b/pandas/core/arrays/interval.py @@ -43,10 +43,7 @@ ) from pandas.compat.numpy import function as nv from pandas.errors import IntCastingNaNError -from pandas.util._decorators import ( - Appender, - deprecate_nonkeyword_arguments, -) +from pandas.util._decorators import Appender from pandas.core.dtypes.cast import LossySetitemError from pandas.core.dtypes.common import ( @@ -796,16 +793,15 @@ 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, kind: SortKind = "quicksort", na_position: str = "last", - *args, **kwargs, ) -> np.ndarray: - ascending = nv.validate_argsort_with_ascending(ascending, args, kwargs) + ascending = nv.validate_argsort_with_ascending(ascending, (), kwargs) if ascending and kind == "quicksort" and na_position == "last": return np.lexsort((self.right, self.left)) diff --git a/pandas/core/base.py b/pandas/core/base.py index 4b147dc619692..5e0694ea91360 100644 --- a/pandas/core/base.py +++ b/pandas/core/base.py @@ -1304,7 +1304,7 @@ def searchsorted( sorter=sorter, ) - def drop_duplicates(self, keep: DropKeep = "first"): + def drop_duplicates(self, *, keep: DropKeep = "first"): duplicated = self._duplicated(keep=keep) # error: Value of type "IndexOpsMixin" is not indexable return self[~duplicated] # type: ignore[index] diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 2809aa9eaa37d..c54eb0bb57747 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -5835,10 +5835,10 @@ def set_index( ) -> None: ... - @deprecate_nonkeyword_arguments(version=None, allowed_args=["self", "keys"]) def set_index( self, keys, + *, drop: bool = True, append: bool = False, inplace: bool = False, @@ -6080,10 +6080,10 @@ def reset_index( ) -> DataFrame | None: ... - @deprecate_nonkeyword_arguments(version=None, allowed_args=["self", "level"]) def reset_index( self, level: IndexLabel = None, + *, drop: bool = False, inplace: bool = False, col_level: Hashable = 0, @@ -6376,9 +6376,9 @@ def dropna( ) -> None: ... - @deprecate_nonkeyword_arguments(version=None, allowed_args=["self"]) def dropna( self, + *, axis: Axis = 0, how: AnyAll | NoDefault = no_default, thresh: int | NoDefault = no_default, @@ -8500,9 +8500,8 @@ def groupby( @Substitution("") @Appender(_shared_docs["pivot"]) - @deprecate_nonkeyword_arguments(version=None, allowed_args=["self"]) def pivot( - self, index=lib.NoDefault, columns=lib.NoDefault, values=lib.NoDefault + self, *, index=lib.NoDefault, columns=lib.NoDefault, values=lib.NoDefault ) -> DataFrame: from pandas.core.reshape.pivot import pivot diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index 241e528fbdc74..7571525363447 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -67,7 +67,6 @@ from pandas.util._decorators import ( Appender, cache_readonly, - deprecate_nonkeyword_arguments, doc, ) from pandas.util._exceptions import ( @@ -2894,8 +2893,7 @@ def unique(self: _IndexT, level: Hashable | None = None) -> _IndexT: result = super().unique() return self._shallow_copy(result) - @deprecate_nonkeyword_arguments(version=None, allowed_args=["self"]) - def drop_duplicates(self: _IndexT, keep: DropKeep = "first") -> _IndexT: + def drop_duplicates(self: _IndexT, *, keep: DropKeep = "first") -> _IndexT: """ Return Index with duplicate values removed. diff --git a/pandas/core/resample.py b/pandas/core/resample.py index 9f9fdef089353..ee738b43a481b 100644 --- a/pandas/core/resample.py +++ b/pandas/core/resample.py @@ -46,7 +46,6 @@ from pandas.util._decorators import ( Appender, Substitution, - deprecate_nonkeyword_arguments, doc, ) @@ -881,11 +880,11 @@ def fillna(self, method, limit=None): """ return self._upsample(method, limit=limit) - @deprecate_nonkeyword_arguments(version=None, allowed_args=["self", "method"]) @doc(NDFrame.interpolate, **_shared_docs_kwargs) def interpolate( self, method: QuantileInterpolation = "linear", + *, axis: Axis = 0, limit=None, inplace: bool = False, diff --git a/pandas/core/series.py b/pandas/core/series.py index 7d6932457ac29..9bfb2a0561532 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -1409,10 +1409,10 @@ def reset_index( ) -> None: ... - @deprecate_nonkeyword_arguments(version=None, allowed_args=["self", "level"]) def reset_index( self, level: IndexLabel = None, + *, drop: bool = False, name: Level = lib.no_default, inplace: bool = False, @@ -2186,23 +2186,22 @@ def unique(self) -> ArrayLike: @overload def drop_duplicates( - self, keep: DropKeep = ..., *, inplace: Literal[False] = ... + self, *, keep: DropKeep = ..., inplace: Literal[False] = ... ) -> Series: ... @overload - def drop_duplicates(self, keep: DropKeep = ..., *, inplace: Literal[True]) -> None: + def drop_duplicates(self, *, keep: DropKeep = ..., inplace: Literal[True]) -> None: ... @overload def drop_duplicates( - self, keep: DropKeep = ..., *, inplace: bool = ... + self, *, keep: DropKeep = ..., inplace: bool = ... ) -> Series | None: ... - @deprecate_nonkeyword_arguments(version=None, allowed_args=["self"]) def drop_duplicates( - self, keep: DropKeep = "first", inplace: bool = False + self, *, keep: DropKeep = "first", inplace: bool = False ) -> Series | None: """ Return Series with duplicate values removed. @@ -5687,9 +5686,9 @@ def dropna( ) -> None: ... - @deprecate_nonkeyword_arguments(version=None, allowed_args=["self"]) def dropna( self, + *, axis: Axis = 0, inplace: bool = False, how: AnyAll | None = None, diff --git a/pandas/io/parsers/readers.py b/pandas/io/parsers/readers.py index abd1182214f5f..1f4c449fc03a1 100644 --- a/pandas/io/parsers/readers.py +++ b/pandas/io/parsers/readers.py @@ -40,7 +40,6 @@ from pandas.util._decorators import ( Appender, deprecate_kwarg, - deprecate_nonkeyword_arguments, ) from pandas.util._exceptions import find_stack_level from pandas.util._validators import validate_bool_kwarg @@ -864,7 +863,6 @@ def read_csv( @deprecate_kwarg(old_arg_name="mangle_dupe_cols", new_arg_name=None) -@deprecate_nonkeyword_arguments(version=None, allowed_args=["filepath_or_buffer"]) @Appender( _doc_read_csv_and_table.format( func_name="read_csv", @@ -877,6 +875,7 @@ def read_csv( ) def read_csv( filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], + *, sep: str | None | lib.NoDefault = lib.no_default, delimiter: str | None | lib.NoDefault = None, # Column and Index Locations and Names @@ -1208,7 +1207,6 @@ def read_table( @deprecate_kwarg(old_arg_name="mangle_dupe_cols", new_arg_name=None) -@deprecate_nonkeyword_arguments(version=None, allowed_args=["filepath_or_buffer"]) @Appender( _doc_read_csv_and_table.format( func_name="read_table", @@ -1221,6 +1219,7 @@ def read_table( ) def read_table( filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], + *, sep: str | None | lib.NoDefault = lib.no_default, delimiter: str | None | lib.NoDefault = None, # Column and Index Locations and Names @@ -1307,9 +1306,9 @@ def read_table( return _read(filepath_or_buffer, kwds) -@deprecate_nonkeyword_arguments(version=None, allowed_args=["filepath_or_buffer"]) def read_fwf( filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], + *, colspecs: Sequence[tuple[int, int]] | str | None = "infer", widths: Sequence[int] | None = None, infer_nrows: int = 100, diff --git a/pandas/tests/frame/methods/test_drop.py b/pandas/tests/frame/methods/test_drop.py index 6e5b97af7c297..e6db7ec8ed3d7 100644 --- a/pandas/tests/frame/methods/test_drop.py +++ b/pandas/tests/frame/methods/test_drop.py @@ -510,18 +510,6 @@ def test_drop_with_duplicate_columns2(self): result = df2.drop("C", axis=1) tm.assert_frame_equal(result, expected) - def test_drop_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\.drop " - r"except for the argument 'labels' will be keyword-only" - ) - with tm.assert_produces_warning(FutureWarning, match=msg): - result = df.drop("a", 1) - expected = DataFrame(index=[0, 1, 2]) - tm.assert_frame_equal(result, expected) - def test_drop_inplace_no_leftover_column_reference(self): # GH 13934 df = DataFrame({"a": [1, 2, 3]}) diff --git a/pandas/tests/frame/methods/test_dropna.py b/pandas/tests/frame/methods/test_dropna.py index 62351aa89c914..8c4d9499e3676 100644 --- a/pandas/tests/frame/methods/test_dropna.py +++ b/pandas/tests/frame/methods/test_dropna.py @@ -231,18 +231,6 @@ def test_dropna_with_duplicate_columns(self): result = df.dropna(subset=["A", "C"], how="all") tm.assert_frame_equal(result, expected) - def test_dropna_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\.dropna " - r"will be keyword-only" - ) - with tm.assert_produces_warning(FutureWarning, match=msg): - result = df.dropna(1) - expected = DataFrame({"a": [1, 2, 3]}) - tm.assert_frame_equal(result, expected) - def test_set_single_column_subset(self): # GH 41021 df = DataFrame({"A": [1, 2, 3], "B": list("abc"), "C": [4, np.NaN, 5]}) diff --git a/pandas/tests/frame/methods/test_reset_index.py b/pandas/tests/frame/methods/test_reset_index.py index 37431bc291b76..30c033572335a 100644 --- a/pandas/tests/frame/methods/test_reset_index.py +++ b/pandas/tests/frame/methods/test_reset_index.py @@ -730,19 +730,6 @@ def test_reset_index_multiindex_nat(): tm.assert_frame_equal(result, expected) -def test_drop_pos_args_deprecation(): - # https://github.com/pandas-dev/pandas/issues/41485 - df = DataFrame({"a": [1, 2, 3]}).set_index("a") - msg = ( - r"In a future version of pandas all arguments of DataFrame\.reset_index " - r"except for the argument 'level' will be keyword-only" - ) - with tm.assert_produces_warning(FutureWarning, match=msg): - result = df.reset_index("a", False) - expected = DataFrame({"a": [1, 2, 3]}) - tm.assert_frame_equal(result, expected) - - def test_reset_index_interval_columns_object_cast(): # GH 19136 df = DataFrame( diff --git a/pandas/tests/frame/methods/test_set_index.py b/pandas/tests/frame/methods/test_set_index.py index 4c39cf99f18ff..8e5f11840fbe5 100644 --- a/pandas/tests/frame/methods/test_set_index.py +++ b/pandas/tests/frame/methods/test_set_index.py @@ -704,15 +704,3 @@ def test_set_index_periodindex(self): tm.assert_index_equal(df.index, idx1) df = df.set_index(idx2) tm.assert_index_equal(df.index, idx2) - - def test_drop_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\.set_index " - r"except for the argument 'keys' will be keyword-only" - ) - with tm.assert_produces_warning(FutureWarning, match=msg): - result = df.set_index("a", True) - expected = DataFrame(index=Index([1, 2, 3], name="a")) - tm.assert_frame_equal(result, expected) diff --git a/pandas/tests/indexes/multi/test_duplicates.py b/pandas/tests/indexes/multi/test_duplicates.py index 509daff1262b4..6c31caac4b42d 100644 --- a/pandas/tests/indexes/multi/test_duplicates.py +++ b/pandas/tests/indexes/multi/test_duplicates.py @@ -326,19 +326,6 @@ def test_duplicated_series_complex_numbers(dtype): tm.assert_series_equal(result, expected) -def test_multi_drop_duplicates_pos_args_deprecation(): - # GH#41485 - idx = MultiIndex.from_arrays([[1, 2, 3, 1], [1, 2, 3, 1]]) - msg = ( - "In a future version of pandas all arguments of " - "Index.drop_duplicates will be keyword-only" - ) - with tm.assert_produces_warning(FutureWarning, match=msg): - result = idx.drop_duplicates("last") - expected = MultiIndex.from_arrays([[2, 3, 1], [2, 3, 1]]) - tm.assert_index_equal(expected, result) - - def test_midx_unique_ea_dtype(): # GH#48335 vals_a = Series([1, 2, NA, NA], dtype="Int64") diff --git a/pandas/tests/indexes/test_base.py b/pandas/tests/indexes/test_base.py index 698bec81e3630..523decba33b6e 100644 --- a/pandas/tests/indexes/test_base.py +++ b/pandas/tests/indexes/test_base.py @@ -1590,20 +1590,6 @@ def test_construct_from_memoryview(klass, extra_kwargs): tm.assert_index_equal(result, expected, exact=True) -def test_drop_duplicates_pos_args_deprecation(): - # GH#41485 - idx = Index([1, 2, 3, 1]) - msg = ( - "In a future version of pandas all arguments of " - "Index.drop_duplicates will be keyword-only" - ) - with tm.assert_produces_warning(FutureWarning, match=msg): - idx.drop_duplicates("last") - result = idx.drop_duplicates("last") - expected = Index([2, 3, 1]) - tm.assert_index_equal(expected, result) - - def test_get_attributes_dict_deprecated(): # https://github.com/pandas-dev/pandas/pull/44028 idx = Index([1, 2, 3, 1]) diff --git a/pandas/tests/io/parser/common/test_common_basic.py b/pandas/tests/io/parser/common/test_common_basic.py index 52d8abe76ecbc..af7ebc5e9555c 100644 --- a/pandas/tests/io/parser/common/test_common_basic.py +++ b/pandas/tests/io/parser/common/test_common_basic.py @@ -805,17 +805,6 @@ def test_read_csv_line_break_as_separator(kwargs, all_parsers): parser.read_csv(StringIO(data), **kwargs) -def test_read_csv_posargs_deprecation(all_parsers): - # GH 41485 - f = StringIO("a,b\n1,2") - parser = all_parsers - msg = ( - "In a future version of pandas all arguments of read_csv " - "except for the argument 'filepath_or_buffer' will be keyword-only" - ) - parser.read_csv_check_warnings(FutureWarning, msg, f, " ") - - @pytest.mark.parametrize("delimiter", [",", "\t"]) def test_read_table_delim_whitespace_non_default_sep(all_parsers, delimiter): # GH: 35958 @@ -941,17 +930,6 @@ def test_short_multi_line(all_parsers): tm.assert_frame_equal(result, expected) -def test_read_table_posargs_deprecation(all_parsers): - # https://github.com/pandas-dev/pandas/issues/41485 - data = StringIO("a\tb\n1\t2") - parser = all_parsers - msg = ( - "In a future version of pandas all arguments of read_table " - "except for the argument 'filepath_or_buffer' will be keyword-only" - ) - parser.read_table_check_warnings(FutureWarning, msg, data, " ") - - def test_read_seek(all_parsers): # GH48646 parser = all_parsers diff --git a/pandas/tests/io/parser/test_read_fwf.py b/pandas/tests/io/parser/test_read_fwf.py index d6d787df39dfa..3e451239dcd40 100644 --- a/pandas/tests/io/parser/test_read_fwf.py +++ b/pandas/tests/io/parser/test_read_fwf.py @@ -910,18 +910,6 @@ def test_skiprows_with_iterator(): tm.assert_frame_equal(result, expected_frames[i]) -def test_skiprows_passing_as_positional_deprecated(): - # GH#41485 - data = """0 -1 -2 -""" - with tm.assert_produces_warning(FutureWarning, match="keyword-only"): - result = read_fwf(StringIO(data), [(0, 2)]) - expected = DataFrame({"0": [1, 2]}) - tm.assert_frame_equal(result, expected) - - def test_names_and_infer_colspecs(): # GH#45337 data = """X Y Z diff --git a/pandas/tests/resample/test_deprecated.py b/pandas/tests/resample/test_deprecated.py index 3aac7a961fa19..e1e042aae1447 100644 --- a/pandas/tests/resample/test_deprecated.py +++ b/pandas/tests/resample/test_deprecated.py @@ -278,30 +278,3 @@ def test_resample_base_with_timedeltaindex(): tm.assert_index_equal(without_base.index, exp_without_base) tm.assert_index_equal(with_base.index, exp_with_base) - - -def test_interpolate_posargs_deprecation(): - # GH 41485 - idx = pd.to_datetime(["1992-08-27 07:46:48", "1992-08-27 07:46:59"]) - s = Series([1, 4], index=idx) - - msg = ( - r"In a future version of pandas all arguments of Resampler\.interpolate " - r"except for the argument 'method' will be keyword-only" - ) - - with tm.assert_produces_warning(FutureWarning, match=msg): - result = s.resample("3s").interpolate("linear", 0) - - idx = pd.to_datetime( - [ - "1992-08-27 07:46:48", - "1992-08-27 07:46:51", - "1992-08-27 07:46:54", - "1992-08-27 07:46:57", - ] - ) - expected = Series([1.0, 1.0, 1.0, 1.0], index=idx) - - expected.index._data.freq = "3s" - tm.assert_series_equal(result, expected) diff --git a/pandas/tests/series/methods/test_drop_duplicates.py b/pandas/tests/series/methods/test_drop_duplicates.py index c5cffa0c9fb0f..698430095b453 100644 --- a/pandas/tests/series/methods/test_drop_duplicates.py +++ b/pandas/tests/series/methods/test_drop_duplicates.py @@ -242,16 +242,3 @@ def test_drop_duplicates_categorical_bool_na(self, nulls_fixture): index=[0, 1, 4], ) tm.assert_series_equal(result, expected) - - -def test_drop_duplicates_pos_args_deprecation(): - # GH#41485 - s = Series(["a", "b", "c", "b"]) - msg = ( - "In a future version of pandas all arguments of " - "Series.drop_duplicates will be keyword-only" - ) - with tm.assert_produces_warning(FutureWarning, match=msg): - result = s.drop_duplicates("last") - expected = Series(["a", "c", "b"], index=[0, 2, 3]) - tm.assert_series_equal(expected, result) diff --git a/pandas/tests/series/methods/test_dropna.py b/pandas/tests/series/methods/test_dropna.py index 0dab9271bfee5..5bff7306fac33 100644 --- a/pandas/tests/series/methods/test_dropna.py +++ b/pandas/tests/series/methods/test_dropna.py @@ -101,15 +101,3 @@ def test_datetime64_tz_dropna(self): ) assert result.dtype == "datetime64[ns, Asia/Tokyo]" tm.assert_series_equal(result, expected) - - def test_dropna_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\.dropna " - r"will be keyword-only" - ) - with tm.assert_produces_warning(FutureWarning, match=msg): - result = ser.dropna(0) - expected = Series([1, 2, 3]) - tm.assert_series_equal(result, expected) diff --git a/pandas/tests/series/methods/test_reset_index.py b/pandas/tests/series/methods/test_reset_index.py index e7340aaf376e5..9362b0b52a698 100644 --- a/pandas/tests/series/methods/test_reset_index.py +++ b/pandas/tests/series/methods/test_reset_index.py @@ -148,18 +148,6 @@ def test_reset_index_with_drop(self, series_with_multilevel_index): assert isinstance(deleveled, Series) assert deleveled.index.name == ser.index.name - def test_drop_pos_args_deprecation(self): - # https://github.com/pandas-dev/pandas/issues/41485 - ser = Series([1, 2, 3], index=Index([1, 2, 3], name="a")) - msg = ( - r"In a future version of pandas all arguments of Series\.reset_index " - r"except for the argument 'level' will be keyword-only" - ) - with tm.assert_produces_warning(FutureWarning, match=msg): - result = ser.reset_index("a", False) - expected = DataFrame({"a": [1, 2, 3], 0: [1, 2, 3]}) - tm.assert_frame_equal(result, expected) - def test_reset_index_inplace_and_drop_ignore_name(self): # GH#44575 ser = Series(range(2), name="old") From 0043c919365c965641a68c2ff431dc741df06245 Mon Sep 17 00:00:00 2001 From: Brock Date: Thu, 27 Oct 2022 15:33:09 -0700 Subject: [PATCH 2/2] fix asv --- asv_bench/benchmarks/reshape.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/asv_bench/benchmarks/reshape.py b/asv_bench/benchmarks/reshape.py index 05e12630d7540..171e4feb290cf 100644 --- a/asv_bench/benchmarks/reshape.py +++ b/asv_bench/benchmarks/reshape.py @@ -36,7 +36,7 @@ def setup(self): self.df = DataFrame(data) def time_reshape_pivot_time_series(self): - self.df.pivot("date", "variable", "value") + self.df.pivot(index="date", columns="variable", values="value") class SimpleReshape: