Skip to content

Enable multi-coord grouping from xarray #9332

Closed
@max-sixty

Description

@max-sixty

I'm working through some around non-trivial groupby from colleagues. In particular, grouping by multiple coordinates seems much harder in xarray than pandas. Flox actually does this really nicely, as per the comment from @dcherian:

As an aside, the API isn't great but this works in flox (I think)

import flox.xarray

flox.xarray.xarray_reduce(da, "labels1", "labels2", func="mean")
image

Originally posted by @dcherian in #9278 (comment)

Would be great if da.groupby(["labels1", "labels2"]).mean() worked too — is that just a simple translation to flox from the xarray code? (I can probably do it if so). Or is there something more complex going on?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions