Skip to content

Commit f02967c

Browse files
nedclimateriskshoyer
authored andcommitted
Include multidimensional stacking groupby in docs (#2493)
1 parent 3f697fe commit f02967c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

doc/groupby.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,3 +207,12 @@ may be desirable:
207207
.. ipython:: python
208208
209209
da.groupby_bins('lon', [0,45,50]).sum()
210+
211+
These methods group by `lon` values. It is also possible to groupby each
212+
cell in a grid, regardless of value, by stacking multiple dimensions,
213+
applying your function, and then unstacking the result:
214+
215+
.. ipython:: python
216+
217+
stacked = da.stack(gridcell=['ny', 'nx'])
218+
stacked.groupby('gridcell').sum().unstack('gridcell')

0 commit comments

Comments
 (0)