Skip to content

Commit f765a91

Browse files
committed
try tz_convert
1 parent cb797e7 commit f765a91

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pandas/plotting/_matplotlib/timeseries.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,11 @@ def _maybe_convert_index(ax, data):
251251
freq = frequencies.get_period_alias(freq)
252252

253253
if isinstance(data.index, ABCDatetimeIndex):
254-
data = data.tz_localize(None).to_period(freq=freq)
254+
if data.index.tz is not None:
255+
data = data.tz_convert(None).to_period(freq=freq)
256+
else:
257+
# can't convert tz-naive
258+
data = data.to_period(freq=freq)
255259
elif isinstance(data.index, ABCPeriodIndex):
256260
data.index = data.index.asfreq(freq=freq)
257261
return data

0 commit comments

Comments
 (0)