Grouping based on other variables

30 Views Asked by At

I have an Xarray dataset with x and y coordinates and 3 variables agb, col and row. You can have an overview looking at this (don't care about other coords/vars)

enter image description here

My goal is to group agb values based on col and row values, as shown here

enter image description here

and then produce a mean for each group, and assign the value to the corresponding (col,row) index in another DataArray, e.g. ( following the example above )

enter image description here

I can't figure out how to do it. I tried using the .groupby() method, but it works on coordinates and not on pairs taken from other variables.

Any suggestion?

Thanks in advance

0

There are 0 best solutions below