Skip to content

Commit e531205

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

File tree

3 files changed

+28
-8
lines changed

3 files changed

+28
-8
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

+16-8
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,27 @@
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+
Plots a Series on the given Matplotlib axes or the current axes
2829
29-
Parameters
30-
----------
31-
axes : Axes
32-
series : Series
30+
Parameters
31+
----------
32+
axes : Axes
33+
series : Series
3334
34-
Notes
35-
_____
36-
Supports same kwargs as Axes.plot
35+
Notes
36+
_____
37+
Supports same kwargs as Axes.plot
3738
39+
40+
.. deprecated:: 0.23.0
41+
Use TimeSeries.plot() instead
3842
"""
43+
warnings.warn("'tsplot' is deprecated and will be removed in a "
44+
"future version. Please use TimeSeries.plot() instead.",
45+
FutureWarning, stacklevel=2)
46+
3947
# Used inferred freq is possible, need a test case for inferred
4048
if ax is None:
4149
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)