Skip to content
forked from pydata/xarray

Commit

Permalink
Fix docs
Browse files Browse the repository at this point in the history
  • Loading branch information
dcherian committed Dec 19, 2023
1 parent 5b33b98 commit 97f1695
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions doc/user-guide/groupby.rst
Original file line number Diff line number Diff line change
Expand Up @@ -177,28 +177,18 @@ This last line is roughly equivalent to the following::
results.append(group - alt.sel(letters=label))
xr.concat(results, dim='x')

Squeezing
~~~~~~~~~
Iterating and Squeezing
~~~~~~~~~~~~~~~~~~~~~~~

When grouping over a dimension, you can control whether the dimension is
squeezed out or if it should remain with length one on each group by using
the ``squeeze`` parameter:

.. ipython:: python
next(iter(arr.groupby("x")))
Previously, Xarray defaulted to squeezing out dimensions of size one when iterating over
a GroupBy object. This behaviour is being removed.
You can always squeeze explicitly later with the Dataset or DataArray
:py:meth:`~xarray.DataArray.squeeze` methods.

.. ipython:: python
next(iter(arr.groupby("x", squeeze=False)))
Although xarray will attempt to automatically
:py:attr:`~xarray.DataArray.transpose` dimensions back into their original order
when you use apply, it is sometimes useful to set ``squeeze=False`` to
guarantee that all original dimensions remain unchanged.

You can always squeeze explicitly later with the Dataset or DataArray
:py:meth:`~xarray.DataArray.squeeze` methods.
.. _groupby.multidim:

Expand Down

0 comments on commit 97f1695

Please sign in to comment.