From 752ed22284421b639652ebb6c0c6f53c57e419f1 Mon Sep 17 00:00:00 2001 From: Wang ChengMeng <79295644+cmw-creator@users.noreply.github.com> Date: Wed, 10 Jun 2026 08:16:18 +0000 Subject: [PATCH] fix: support pandas >= 3.0.0 Day offset division for resampled time coordinates (#179) --- reshapr/core/extract.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/reshapr/core/extract.py b/reshapr/core/extract.py index 7c4366b..55e4263 100644 --- a/reshapr/core/extract.py +++ b/reshapr/core/extract.py @@ -1001,7 +1001,11 @@ def _calc_resampled_time_coord(resampled_time_index, freq): # pandas 2.2.0 deprecated the M, Q & Y frequency aliases in favour of ME, QE & YE # We interpreted M to mean MS. Now we accept both for backward compatibility. if not freq.endswith(("M", "MS")): - offsets = pandas.tseries.frequencies.to_offset(freq) / 2 + offset = pandas.tseries.frequencies.to_offset(freq) + # pandas >= 3.0.0 removed support for dividing Day offsets + # Use anchor timestamp to compute half-offset duration safely + anchor = pandas.Timestamp("2000-01-01") + offsets = (anchor + offset - anchor) / 2 return resampled_time_index + offsets offsets = [ pandas.tseries.frequencies.to_offset(