xarray-contrib / flox

Fast & furious GroupBy operations for dask.array
https://flox.readthedocs.io
Apache License 2.0
124 stars 18 forks source link

Support xarray grouper objects in xarray interface #256

Open dcherian opened 1 year ago

dcherian commented 1 year ago

I think we need a new much improved interface that only uses Grouper objects following the API in https://github.com/pydata/xarray/issues/6610#issuecomment-1523666774, and potentially using a flox accessor (this may be a lot quicker than adding multiple grouper support to xarray directly)

We will need to make the Grouper objects public in Xarray first, but that's not a bad blocker.

data.flox.groupby({
    "x0": xr.BinGrouper(bins=pd.IntervalIndex.from_breaks(coords["x_vertices"])),  # binning
    "y": xr.UniqueGrouper(labels=["a", "b", "c"]),  # categorical, data.y is dask-backed
    "time": xr.TimeResampleGrouper(freq="MS")
    },
)