diff --git a/doc/source/whatsnew/v1.0.0.rst b/doc/source/whatsnew/v1.0.0.rst index b93856db6ba8d0..a646c4aa03687d 100644 --- a/doc/source/whatsnew/v1.0.0.rst +++ b/doc/source/whatsnew/v1.0.0.rst @@ -614,6 +614,7 @@ or ``matplotlib.Axes.plot``. See :ref:`plotting.formatters` for more. - Changed :meth:`Timedelta.resolution` to match the behavior of the standard library ``datetime.timedelta.resolution``, for the old behavior, use :meth:`Timedelta.resolution_string` (:issue:`26839`) - Removed previously deprecated :attr:`Timestamp.weekday_name`, :attr:`DatetimeIndex.weekday_name`, and :attr:`Series.dt.weekday_name` (:issue:`18164`) - Removed previously deprecated ``errors`` argument in :meth:`Timestamp.tz_localize`, :meth:`DatetimeIndex.tz_localize`, and :meth:`Series.tz_localize` (:issue:`22644`) +- :meth:`Series.set_axis` and :meth:`DataFrame.set_axis` now require "labels" as the first argument and "axis" as an optional named parameter (:issue:`30089`) - .. _whatsnew_1000.performance: diff --git a/pandas/core/generic.py b/pandas/core/generic.py index bcc742e731110e..3e41721b65f5d3 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -633,17 +633,6 @@ def set_axis(self, labels, axis=0, inplace=False): 1 2 5 2 3 6 """ - if is_scalar(labels): - warnings.warn( - 'set_axis now takes "labels" as first argument, and ' - '"axis" as named parameter. The old form, with "axis" as ' - 'first parameter and "labels" as second, is still supported ' - "but will be deprecated in a future version of pandas.", - FutureWarning, - stacklevel=2, - ) - labels, axis = axis, labels - if inplace: setattr(self, self._get_axis_name(axis), labels) else: diff --git a/pandas/tests/frame/test_alter_axes.py b/pandas/tests/frame/test_alter_axes.py index b52f24f9e06f12..48b373d9c7901e 100644 --- a/pandas/tests/frame/test_alter_axes.py +++ b/pandas/tests/frame/test_alter_axes.py @@ -1548,21 +1548,3 @@ def test_set_axis_inplace(self): for axis in 3, "foo": with pytest.raises(ValueError, match="No axis named"): df.set_axis(list("abc"), axis=axis) - - def test_set_axis_prior_to_deprecation_signature(self): - df = DataFrame( - {"A": [1.1, 2.2, 3.3], "B": [5.0, 6.1, 7.2], "C": [4.4, 5.5, 6.6]}, - index=[2010, 2011, 2012], - ) - - expected = {0: df.copy(), 1: df.copy()} - expected[0].index = list("abc") - expected[1].columns = list("abc") - expected["index"] = expected[0] - expected["columns"] = expected[1] - - # old signature - for axis in expected: - with tm.assert_produces_warning(FutureWarning): - result = df.set_axis(axis, list("abc"), inplace=False) - tm.assert_frame_equal(result, expected[axis]) diff --git a/pandas/tests/series/test_alter_axes.py b/pandas/tests/series/test_alter_axes.py index 7a24a45b4b6c2e..9e1bae84691380 100644 --- a/pandas/tests/series/test_alter_axes.py +++ b/pandas/tests/series/test_alter_axes.py @@ -322,17 +322,6 @@ def test_set_axis_inplace(self): with pytest.raises(ValueError, match="No axis named"): s.set_axis(list("abcd"), axis=axis, inplace=False) - def test_set_axis_prior_to_deprecation_signature(self): - s = Series(np.arange(4), index=[1, 3, 5, 7], dtype="int64") - - expected = s.copy() - expected.index = list("abcd") - - for axis in [0, "index"]: - with tm.assert_produces_warning(FutureWarning): - result = s.set_axis(0, list("abcd"), inplace=False) - tm.assert_series_equal(result, expected) - def test_reset_index_drop_errors(self): # GH 20925