Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport PR #31207 on branch 1.0.x (BUG: no longer raise user warning when plotting tz aware time series) #31601

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v1.0.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ I/O
Plotting
^^^^^^^^

-
- Plotting tz-aware timeseries no longer gives UserWarning (:issue:`31205`)
-

Groupby/resample/rolling
Expand Down
2 changes: 1 addition & 1 deletion pandas/plotting/_matplotlib/timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ def _maybe_convert_index(ax, data):
freq = frequencies.get_period_alias(freq)

if isinstance(data.index, ABCDatetimeIndex):
data = data.to_period(freq=freq)
data = data.tz_localize(None).to_period(freq=freq)
elif isinstance(data.index, ABCPeriodIndex):
data.index = data.index.asfreq(freq=freq)
return data
Expand Down
5 changes: 3 additions & 2 deletions pandas/tests/plotting/test_datetimelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,12 @@ def teardown_method(self, method):

@pytest.mark.slow
def test_ts_plot_with_tz(self, tz_aware_fixture):
# GH2877, GH17173
# GH2877, GH17173, GH31205
tz = tz_aware_fixture
index = date_range("1/1/2011", periods=2, freq="H", tz=tz)
ts = Series([188.5, 328.25], index=index)
_check_plot_works(ts.plot)
with tm.assert_produces_warning(None):
_check_plot_works(ts.plot)

def test_fontsize_set_correctly(self):
# For issue #8765
Expand Down