Skip to content

Commit 62757c4

Browse files
authored
DEPR: Remove sort_columns in plotting (#49315)
1 parent eef20d3 commit 62757c4

File tree

4 files changed

+1
-36
lines changed

4 files changed

+1
-36
lines changed

doc/source/whatsnew/v2.0.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ Removal of prior version deprecations/changes
189189
- Removed argument ``how`` from :meth:`PeriodIndex.astype`, use :meth:`PeriodIndex.to_timestamp` instead (:issue:`37982`)
190190
- Removed argument ``try_cast`` from :meth:`DataFrame.mask`, :meth:`DataFrame.where`, :meth:`Series.mask` and :meth:`Series.where` (:issue:`38836`)
191191
- Removed argument ``tz`` from :meth:`Period.to_timestamp`, use ``obj.to_timestamp(...).tz_localize(tz)`` instead (:issue:`34522`)
192+
- Removed argument ``sort_columns`` in :meth:`DataFrame.plot` and :meth:`Series.plot` (:issue:`47563`)
192193
- Removed argument ``is_copy`` from :meth:`DataFrame.take` and :meth:`Series.take` (:issue:`30615`)
193194
- Removed argument ``kind`` from :meth:`Index.get_slice_bound`, :meth:`Index.slice_indexer` and :meth:`Index.slice_locs` (:issue:`41378`)
194195
- Removed argument ``inplace`` from :meth:`Categorical.remove_unused_categories` (:issue:`37918`)

pandas/plotting/_core.py

-19
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
from __future__ import annotations
22

33
import importlib
4-
import itertools
54
import types
65
from typing import (
76
TYPE_CHECKING,
87
Sequence,
98
)
10-
import warnings
119

1210
from pandas._config import get_option
1311

@@ -16,7 +14,6 @@
1614
Appender,
1715
Substitution,
1816
)
19-
from pandas.util._exceptions import find_stack_level
2017

2118
from pandas.core.dtypes.common import (
2219
is_integer,
@@ -760,13 +757,6 @@ class PlotAccessor(PandasObject):
760757
Equivalent to yerr.
761758
stacked : bool, default False in line and bar plots, and True in area plot
762759
If True, create stacked plot.
763-
sort_columns : bool, default False
764-
Sort column names to determine plot ordering.
765-
766-
.. deprecated:: 1.5.0
767-
The `sort_columns` arguments is deprecated and will be removed in a
768-
future version.
769-
770760
secondary_y : bool or sequence, default False
771761
Whether to plot on the secondary y-axis if a list/tuple, which
772762
columns to plot on secondary y-axis.
@@ -877,7 +867,6 @@ def _get_call_args(backend_name, data, args, kwargs):
877867
("yerr", None),
878868
("xerr", None),
879869
("secondary_y", False),
880-
("sort_columns", False),
881870
("xlabel", None),
882871
("ylabel", None),
883872
]
@@ -887,14 +876,6 @@ def _get_call_args(backend_name, data, args, kwargs):
887876
"expected Series or DataFrame"
888877
)
889878

890-
if "sort_columns" in itertools.chain(args, kwargs.keys()):
891-
warnings.warn(
892-
"`sort_columns` is deprecated and will be removed in a future "
893-
"version.",
894-
FutureWarning,
895-
stacklevel=find_stack_level(),
896-
)
897-
898879
if args and isinstance(data, ABCSeries):
899880
positional_args = str(args)[1:-1]
900881
keyword_args = ", ".join(

pandas/plotting/_matplotlib/core.py

-2
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ def __init__(
138138
yticks=None,
139139
xlabel: Hashable | None = None,
140140
ylabel: Hashable | None = None,
141-
sort_columns: bool = False,
142141
fontsize=None,
143142
secondary_y: bool | tuple | list | np.ndarray = False,
144143
colormap=None,
@@ -184,7 +183,6 @@ def __init__(
184183

185184
self.kind = kind
186185

187-
self.sort_columns = sort_columns
188186
self.subplots = self._validate_subplots_kwarg(subplots)
189187

190188
if sharex is None:

pandas/tests/plotting/frame/test_frame.py

-15
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,6 @@ def test_plot(self):
7676

7777
ax = _check_plot_works(df.plot, use_index=True)
7878
self._check_ticks_props(ax, xrot=0)
79-
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
80-
_check_plot_works(df.plot, sort_columns=False)
8179
_check_plot_works(df.plot, yticks=[1, 5, 10])
8280
_check_plot_works(df.plot, xticks=[1, 5, 10])
8381
_check_plot_works(df.plot, ylim=(-100, 100), xlim=(-100, 100))
@@ -2232,19 +2230,6 @@ def test_secondary_y(self, secondary_y):
22322230
assert ax.get_ylim() == (0, 100)
22332231
assert ax.get_yticks()[0] == 99
22342232

2235-
def test_sort_columns_deprecated(self):
2236-
# GH 47563
2237-
df = DataFrame({"a": [1, 2], "b": [3, 4]})
2238-
2239-
with tm.assert_produces_warning(FutureWarning):
2240-
df.plot.box("a", sort_columns=True)
2241-
2242-
with tm.assert_produces_warning(FutureWarning):
2243-
df.plot.box(sort_columns=False)
2244-
2245-
with tm.assert_produces_warning(False):
2246-
df.plot.box("a")
2247-
22482233

22492234
def _generate_4_axes_via_gridspec():
22502235
import matplotlib as mpl

0 commit comments

Comments
 (0)