79611120

Date: 2025-05-07 17:35:47
Score: 1.5
Natty:
Report link

On latest Xarray (>2024.04.0) you can do

import xarray as xr
from xarray.groupers import SeasonResampler

ds = xr.tutorial.open_dataset("air_temperature")

ds.resample(time=SeasonResampler(["DJFM", "AMJ", "SON"])).mean()

This should correctly handle seasons that span Dec 31/Jan1

https://docs.xarray.dev/en/latest/user-guide/time-series.html#handling-seasons

Reasons:
  • Probably link only (1):
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: dcherian