From 2c68981a06d70c33f342aa411b6866109560ad09 Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Thu, 5 Dec 2019 11:48:02 -0800 Subject: [PATCH 1/2] DEPR: enforce deprecation of old set_axis signature --- doc/source/whatsnew/v1.0.0.rst | 1 + pandas/core/generic.py | 11 ----------- pandas/tests/frame/test_alter_axes.py | 18 ------------------ pandas/tests/series/test_alter_axes.py | 11 ----------- 4 files changed, 1 insertion(+), 40 deletions(-) diff --git a/doc/source/whatsnew/v1.0.0.rst b/doc/source/whatsnew/v1.0.0.rst index 4ce4c12483b36..1d341248ca608 100644 --- a/doc/source/whatsnew/v1.0.0.rst +++ b/doc/source/whatsnew/v1.0.0.rst @@ -594,6 +594,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:`????`) - .. _whatsnew_1000.performance: diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 9aecd97194aad..315c152cdf817 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -632,17 +632,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 b52f24f9e06f1..48b373d9c7901 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 7a24a45b4b6c2..9e1bae8469138 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 From aa0b36e626c18a5825264cd9ba9425f4ea8e46ef Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Thu, 5 Dec 2019 11:48:41 -0800 Subject: [PATCH 2/2] update GH ref --- doc/source/whatsnew/v1.0.0.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v1.0.0.rst b/doc/source/whatsnew/v1.0.0.rst index 1d341248ca608..ac67303f4f351 100644 --- a/doc/source/whatsnew/v1.0.0.rst +++ b/doc/source/whatsnew/v1.0.0.rst @@ -594,7 +594,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:`????`) +- :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: