Skip to content

Commit ad527cd

Browse files
committed
CLN: deprecate the pandas.tseries.plotting.tsplot function (GH18627)
1 parent 5f271eb commit ad527cd

File tree

3 files changed

+18
-11
lines changed

3 files changed

+18
-11
lines changed

doc/source/whatsnew/v0.23.0.txt

+2
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,8 @@ Deprecations
678678
- The ``reduce`` parameter of ``.apply()`` is deprecated in favor of ``result_type='reduce'`` (:issue:`18577`)
679679
- The ``order`` parameter of :func:`factorize` is deprecated and will be removed in a future release (:issue:`19727`)
680680

681+
- ``pandas.tseries.plotting.tsplot`` is deprecated. Use :func:`TimeSeries.plot` instead (:issue:`18627`)
682+
681683
.. _whatsnew_0230.prior_deprecations:
682684

683685
Removal of prior version deprecations/changes

pandas/plotting/_timeseries.py

+6-11
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,14 @@
2323

2424

2525
def tsplot(series, plotf, ax=None, **kwargs):
26+
import warnings
2627
"""
27-
Plots a Series on the given Matplotlib axes or the current axes
28-
29-
Parameters
30-
----------
31-
axes : Axes
32-
series : Series
33-
34-
Notes
35-
_____
36-
Supports same kwargs as Axes.plot
37-
28+
DEPRECATED: use ts.plot() instead
3829
"""
30+
warnings.warn("'tsplot' is deprecated and will be removed in a "
31+
"future version. Please use ts.plot() instead.",
32+
FutureWarning, stacklevel=2)
33+
3934
# Used inferred freq is possible, need a test case for inferred
4035
if ax is None:
4136
import matplotlib.pyplot as plt

pandas/tests/plotting/test_datetimelike.py

+10
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,16 @@ def test_nonnumeric_exclude(self):
100100

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

103+
@pytest.mark.slow
104+
def test_tsplot_deprecated(self):
105+
from pandas.tseries.plotting import tsplot
106+
107+
_, ax = self.plt.subplots()
108+
ts = tm.makeTimeSeries()
109+
110+
with tm.assert_produces_warning(FutureWarning):
111+
tsplot(ts, self.plt.Axes.plot, ax=ax)
112+
103113
@pytest.mark.slow
104114
def test_tsplot(self):
105115
from pandas.tseries.plotting import tsplot

0 commit comments

Comments
 (0)