From 21c079d3e1534b7e5e482f6650adbdfac8e9738a Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Tue, 25 Oct 2022 14:19:21 -0700 Subject: [PATCH] DEPR: Remove sort_columns in plotting --- doc/source/whatsnew/v2.0.0.rst | 1 + pandas/plotting/_core.py | 19 ------------------- pandas/plotting/_matplotlib/core.py | 2 -- pandas/tests/plotting/frame/test_frame.py | 15 --------------- 4 files changed, 1 insertion(+), 36 deletions(-) diff --git a/doc/source/whatsnew/v2.0.0.rst b/doc/source/whatsnew/v2.0.0.rst index 8a628dbce3ca7..6725a3f466b62 100644 --- a/doc/source/whatsnew/v2.0.0.rst +++ b/doc/source/whatsnew/v2.0.0.rst @@ -189,6 +189,7 @@ Removal of prior version deprecations/changes - Removed argument ``how`` from :meth:`PeriodIndex.astype`, use :meth:`PeriodIndex.to_timestamp` instead (:issue:`37982`) - Removed argument ``try_cast`` from :meth:`DataFrame.mask`, :meth:`DataFrame.where`, :meth:`Series.mask` and :meth:`Series.where` (:issue:`38836`) - Removed argument ``tz`` from :meth:`Period.to_timestamp`, use ``obj.to_timestamp(...).tz_localize(tz)`` instead (:issue:`34522`) +- Removed argument ``sort_columns`` in :meth:`DataFrame.plot` and :meth:`Series.plot` (:issue:`47563`) - Removed argument ``is_copy`` from :meth:`DataFrame.take` and :meth:`Series.take` (:issue:`30615`) - Removed argument ``kind`` from :meth:`Index.get_slice_bound`, :meth:`Index.slice_indexer` and :meth:`Index.slice_locs` (:issue:`41378`) - Removed argument ``inplace`` from :meth:`Categorical.remove_unused_categories` (:issue:`37918`) diff --git a/pandas/plotting/_core.py b/pandas/plotting/_core.py index e340ea31deef4..036d2c84f006e 100644 --- a/pandas/plotting/_core.py +++ b/pandas/plotting/_core.py @@ -1,13 +1,11 @@ from __future__ import annotations import importlib -import itertools import types from typing import ( TYPE_CHECKING, Sequence, ) -import warnings from pandas._config import get_option @@ -16,7 +14,6 @@ Appender, Substitution, ) -from pandas.util._exceptions import find_stack_level from pandas.core.dtypes.common import ( is_integer, @@ -760,13 +757,6 @@ class PlotAccessor(PandasObject): Equivalent to yerr. stacked : bool, default False in line and bar plots, and True in area plot If True, create stacked plot. - sort_columns : bool, default False - Sort column names to determine plot ordering. - - .. deprecated:: 1.5.0 - The `sort_columns` arguments is deprecated and will be removed in a - future version. - secondary_y : bool or sequence, default False Whether to plot on the secondary y-axis if a list/tuple, which columns to plot on secondary y-axis. @@ -877,7 +867,6 @@ def _get_call_args(backend_name, data, args, kwargs): ("yerr", None), ("xerr", None), ("secondary_y", False), - ("sort_columns", False), ("xlabel", None), ("ylabel", None), ] @@ -887,14 +876,6 @@ def _get_call_args(backend_name, data, args, kwargs): "expected Series or DataFrame" ) - if "sort_columns" in itertools.chain(args, kwargs.keys()): - warnings.warn( - "`sort_columns` is deprecated and will be removed in a future " - "version.", - FutureWarning, - stacklevel=find_stack_level(), - ) - if args and isinstance(data, ABCSeries): positional_args = str(args)[1:-1] keyword_args = ", ".join( diff --git a/pandas/plotting/_matplotlib/core.py b/pandas/plotting/_matplotlib/core.py index 5c3a79927ec2f..9bcb51a7b032a 100644 --- a/pandas/plotting/_matplotlib/core.py +++ b/pandas/plotting/_matplotlib/core.py @@ -138,7 +138,6 @@ def __init__( yticks=None, xlabel: Hashable | None = None, ylabel: Hashable | None = None, - sort_columns: bool = False, fontsize=None, secondary_y: bool | tuple | list | np.ndarray = False, colormap=None, @@ -184,7 +183,6 @@ def __init__( self.kind = kind - self.sort_columns = sort_columns self.subplots = self._validate_subplots_kwarg(subplots) if sharex is None: diff --git a/pandas/tests/plotting/frame/test_frame.py b/pandas/tests/plotting/frame/test_frame.py index 44f57b02d0f0a..455bc177d43e2 100644 --- a/pandas/tests/plotting/frame/test_frame.py +++ b/pandas/tests/plotting/frame/test_frame.py @@ -76,8 +76,6 @@ def test_plot(self): ax = _check_plot_works(df.plot, use_index=True) self._check_ticks_props(ax, xrot=0) - with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): - _check_plot_works(df.plot, sort_columns=False) _check_plot_works(df.plot, yticks=[1, 5, 10]) _check_plot_works(df.plot, xticks=[1, 5, 10]) _check_plot_works(df.plot, ylim=(-100, 100), xlim=(-100, 100)) @@ -2232,19 +2230,6 @@ def test_secondary_y(self, secondary_y): assert ax.get_ylim() == (0, 100) assert ax.get_yticks()[0] == 99 - def test_sort_columns_deprecated(self): - # GH 47563 - df = DataFrame({"a": [1, 2], "b": [3, 4]}) - - with tm.assert_produces_warning(FutureWarning): - df.plot.box("a", sort_columns=True) - - with tm.assert_produces_warning(FutureWarning): - df.plot.box(sort_columns=False) - - with tm.assert_produces_warning(False): - df.plot.box("a") - def _generate_4_axes_via_gridspec(): import matplotlib as mpl