Skip to content

Commit

Permalink
CLN: deprecate the pandas.tseries.plotting.tsplot function (GH18627) (p…
Browse files Browse the repository at this point in the history
  • Loading branch information
GGordonGordon authored and jorisvandenbossche committed Mar 6, 2018
1 parent aedbd94 commit 8a084eb
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions doc/source/whatsnew/v0.23.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,8 @@ Deprecations
- The ``order`` parameter of :func:`factorize` is deprecated and will be removed in a future release (:issue:`19727`)
- :attr:`Timestamp.weekday_name`, :attr:`DatetimeIndex.weekday_name`, and :attr:`Series.dt.weekday_name` are deprecated in favor of :meth:`Timestamp.day_name`, :meth:`DatetimeIndex.day_name`, and :meth:`Series.dt.day_name` (:issue:`12806`)

- ``pandas.tseries.plotting.tsplot`` is deprecated. Use :func:`Series.plot` instead (:issue:`18627`)

.. _whatsnew_0230.prior_deprecations:

Removal of prior version deprecations/changes
Expand Down
8 changes: 8 additions & 0 deletions pandas/plotting/_timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@


def tsplot(series, plotf, ax=None, **kwargs):
import warnings
"""
Plots a Series on the given Matplotlib axes or the current axes
Expand All @@ -35,7 +36,14 @@ def tsplot(series, plotf, ax=None, **kwargs):
_____
Supports same kwargs as Axes.plot
.. deprecated:: 0.23.0
Use Series.plot() instead
"""
warnings.warn("'tsplot' is deprecated and will be removed in a "
"future version. Please use Series.plot() instead.",
FutureWarning, stacklevel=2)

# Used inferred freq is possible, need a test case for inferred
if ax is None:
import matplotlib.pyplot as plt
Expand Down
9 changes: 9 additions & 0 deletions pandas/tests/plotting/test_datetimelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,15 @@ def test_nonnumeric_exclude(self):

pytest.raises(TypeError, df['A'].plot)

def test_tsplot_deprecated(self):
from pandas.tseries.plotting import tsplot

_, ax = self.plt.subplots()
ts = tm.makeTimeSeries()

with tm.assert_produces_warning(FutureWarning):
tsplot(ts, self.plt.Axes.plot, ax=ax)

@pytest.mark.slow
def test_tsplot(self):
from pandas.tseries.plotting import tsplot
Expand Down

0 comments on commit 8a084eb

Please sign in to comment.