From 7ec23411b06d228fd1a567be0ab7cd0d9f8b31fd Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Sat, 17 Aug 2024 13:43:45 -0700 Subject: [PATCH] Add example to docs fix docs [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- doc/user-guide/groupby.rst | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/doc/user-guide/groupby.rst b/doc/user-guide/groupby.rst index b41bf3eeb3a..42acc75a014 100644 --- a/doc/user-guide/groupby.rst +++ b/doc/user-guide/groupby.rst @@ -81,9 +81,11 @@ You can index out a particular group: ds.groupby("letters")["b"] -Just like in pandas, creating a GroupBy object is cheap: it does not actually +Just like in pandas, creating a ``GroupBy`` object is cheap: it does not actually split the data until you access particular values. +To group by multiple variables, see the section on `Grouper Objects`_ + Binning ~~~~~~~ @@ -276,7 +278,15 @@ is identical to ds.groupby(x=UniqueGrouper()) -and +We can use this to group by multiple dimensions: + +.. ipython:: python + + from xarray.groupers import UniqueGrouper + + ds.groupby(lat=UniqueGrouper(), lon=UniqueGrouper()).sum() + +Similarly, .. code-block:: python