From ac4d73c2851164d054c271e10c9c544024a71d49 Mon Sep 17 00:00:00 2001 From: nedclimaterisk <43126798+nedclimaterisk@users.noreply.github.com> Date: Fri, 19 Oct 2018 18:54:28 +1100 Subject: [PATCH] Include multidimensional stacking groupby in docs --- doc/groupby.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/doc/groupby.rst b/doc/groupby.rst index 4851cbe5dcc..6e42dbbc9f0 100644 --- a/doc/groupby.rst +++ b/doc/groupby.rst @@ -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')