Open
Description
ideally GroupBy._infer_concat_args()
would return a xr.Coordinates
object that contains both the coordinate(s) and their (multi-)index to assign to the result (combined) object.
The goal is to avoid calling create_default_index_implicit(coord)
below where coord
is a pd.MultiIndex
or a single IndexVariable
wrapping a multi-index. If coord
is a Coordinates
object, we could do combined = combined.assign_coords(coord)
instead.
Lines 1573 to 1587 in e2b6f34
There are actually more general issues:
- The
group
parameter of Dataset.groupby being a single variable or variable name, it won't be possible to do groupby on a full pandas multi-index once we drop its dimension coordinate (Deprecate the multi-index dimension coordinate #8143). How can we still support it? Maybe passing a dimension name togroup
and check that there's only one index for that dimension? - How can we support custom, multi-coordinate indexes with groupby? I don't have any practical example in mind, but in theory just passing a single coordinate name as
group
will invalidate the index. Should we drop the index in the result? Or, like suggested above pass a dimension name as group and check the index?
Originally posted by @benbovy in #8140 (comment)
Metadata
Metadata
Assignees
Type
Projects
Status
To do