Skip to content

Commit dc70e9b

Browse files
committed
CLN: deprecate the pandas.tseries.plotting.tsplot function (GH18627)
1 parent 607910b commit dc70e9b

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

Diff for: doc/source/whatsnew/v0.23.0.txt

+2
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,8 @@ Deprecations
731731
- The ``order`` parameter of :func:`factorize` is deprecated and will be removed in a future release (:issue:`19727`)
732732
- :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`)
733733

734+
- ``pandas.tseries.plotting.tsplot`` is deprecated. Use :func:`Series.plot` instead (:issue:`18627`)
735+
734736
.. _whatsnew_0230.prior_deprecations:
735737

736738
Removal of prior version deprecations/changes

Diff for: 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 Series.plot() instead
3842
"""
43+
warnings.warn("'tsplot' is deprecated and will be removed in a "
44+
"future version. Please use Series.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

Diff for: pandas/tests/plotting/test_datetimelike.py

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

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

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

0 commit comments

Comments
 (0)