Skip to content

Commit b3ddf8b

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

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
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

+8
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424

2525
def tsplot(series, plotf, ax=None, **kwargs):
26+
import warnings
2627
"""
2728
Plots a Series on the given Matplotlib axes or the current axes
2829
@@ -35,7 +36,14 @@ def tsplot(series, plotf, ax=None, **kwargs):
3536
_____
3637
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)