From f0086d7afe62b6dd838bbbc2dd949b59bc782ebe Mon Sep 17 00:00:00 2001 From: Mohammed Date: Fri, 7 Nov 2025 00:21:55 +0530 Subject: [PATCH] Fix tz-aware comparison in plot() causing failures at DST boundary --- pandas/plotting/_matplotlib/timeseries.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pandas/plotting/_matplotlib/timeseries.py b/pandas/plotting/_matplotlib/timeseries.py index e489b6a5e8f30..5895499c98f76 100644 --- a/pandas/plotting/_matplotlib/timeseries.py +++ b/pandas/plotting/_matplotlib/timeseries.py @@ -251,7 +251,14 @@ def use_dynamic_x(ax: Axes, index: Index) -> bool: return index[:1].is_normalized period = Period(index[0], freq_str) assert isinstance(period, Period) - return period.to_timestamp().tz_localize(index.tz) == index[0] + if index.tz is not None: + # Compare naive local times directly + period_naive = period.to_timestamp() + index_naive = index[0].tz_localize(None) # Strips tz, keeps local time + return period_naive == index_naive + else: + return period.to_timestamp() == index[0] + return True