Deepak Cherian
Deepak Cherian
> ds.air.groupby(time=SeasonGrouper(["DJFM", "MAMJ", "JJAS", "SOND"])).mean() I went back to my dev notebook, turns out I figured this out already!
Yes, I think so this is conceptually similar to `groupby(["time.month", "time.year"])` but we require dict inputs to be explicit ```python ds.air.groupby( {"time.year": UniqueGrouper(), "time": SeasonGrouper(["JF", "MAM", "JJAS", "OND"])} ).mean() ```...
Yes it tried to be that smart
@tomvothecoder @oliviermarti i fixed the existing tests now, please try it out! FWIW the need to support `seasons=["JJAS"]` is adding quite some complexity. We should consider not supporting it.
Ah nice find. A PR to this branch should be the easiest
@tomvothecoder my mistake. that is a "resampling" operation, so ```python da.resample(time=SeasonResampler(["NDJFM", "AMJ"], drop_incomplete=False)).mean() ``` gives what you want: ``` Size: 40B array([1.25 , 1.61666667, 1.49 , 1.5 , 1.625 ])...
@oliviermarti & @tomvothecoder are you able to do one more test run here? It's basically complete though could use more tests as always.
This PR branch is the branch: https://github.com/dcherian/xarray/tree/custom-groupers
If you like this PR/API please voice support here: https://github.com/pydata/xarray/issues/10198 (a :+1: on the OP would be enough)
I see it here: https://github.com/dcherian/xarray/blob/0d8210a6a5ffda32b80406ac077fec40a2a4fa15/xarray/groupers.py#L729 if you have the Github CLI it should be ``` git clone [email protected]:pydata/xarray.git gh pr checkout 9524 ``` or ``` git clone [email protected]:dcherian/xarray.git git switch...