Skip to content

Commit

Permalink
Include multidimensional stacking groupby in docs (#2493)
Browse files Browse the repository at this point in the history
  • Loading branch information
nedclimaterisk authored and shoyer committed Oct 23, 2018
1 parent 3f697fe commit f02967c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions doc/groupby.rst
Original file line number Diff line number Diff line change
Expand Up @@ -207,3 +207,12 @@ may be desirable:
.. ipython:: python
da.groupby_bins('lon', [0,45,50]).sum()
These methods group by `lon` values. It is also possible to groupby each
cell in a grid, regardless of value, by stacking multiple dimensions,
applying your function, and then unstacking the result:

.. ipython:: python
stacked = da.stack(gridcell=['ny', 'nx'])
stacked.groupby('gridcell').sum().unstack('gridcell')

0 comments on commit f02967c

Please sign in to comment.