Skip to content

DEPR: Remove sort_columns in plotting #49315

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/source/whatsnew/v2.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
Expand Down
19 changes: 0 additions & 19 deletions pandas/plotting/_core.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -16,7 +14,6 @@
Appender,
Substitution,
)
from pandas.util._exceptions import find_stack_level

from pandas.core.dtypes.common import (
is_integer,
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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),
]
Expand All @@ -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(
Expand Down
2 changes: 0 additions & 2 deletions pandas/plotting/_matplotlib/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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:
Expand Down
15 changes: 0 additions & 15 deletions pandas/tests/plotting/frame/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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
Expand Down