Support groupby for multiple coordinates along the same dimension #6044
Answered
by
dcherian
raj-magesh
asked this question in
Ideas
-
As discussed here, it would be great to have native support for grouping along multiple coordinates along the same dimension. |
Beta Was this translation helpful? Give feedback.
Answered by
dcherian
Dec 3, 2021
Replies: 1 comment 4 replies
-
import xarray as xr
d = xr.DataArray([[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]],
coords={
'a': ('dim1',['A', 'A', 'B', 'B']),
'b': ('dim1',['1', '2', '1', '2']),
'c': ('dim2',['x', 'y', 'z'])
},
dims=['dim1', 'dim2'])
d
Does flox do what you want? import flox.xarray
flox.xarray.xarray_reduce(d, "a", "b", func="sum")
|
Beta Was this translation helpful? Give feedback.
4 replies
Answer selected by
raj-magesh
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Does flox do what you want?