🍾 Xarray is now 10 years old! 🎉

xarray.core.groupby.DatasetGroupBy.reduce

xarray.core.groupby.DatasetGroupBy.reduce#

DatasetGroupBy.reduce(func, dim=None, *, axis=None, keep_attrs=None, keepdims=False, shortcut=True, **kwargs)[source]#

Reduce the items in this group by applying func along some dimension(s).

Parameters:
  • func (callable()) – Function which can be called in the form func(x, axis=axis, **kwargs) to return the result of collapsing an np.ndarray over an integer valued axis.

  • dim (..., str, Iterable of Hashable or None, optional) – Dimension(s) over which to apply func. By default apply over the groupby dimension, with “…” apply over all dimensions.

  • axis (int or sequence of int, optional) – Axis(es) over which to apply func. Only one of the ‘dimension’ and ‘axis’ arguments can be supplied. If neither are supplied, then func is calculated over all dimension for each group item.

  • keep_attrs (bool, optional) – If True, the datasets’s attributes (attrs) will be copied from the original object to the new one. If False (default), the new object will be returned without attributes.

  • **kwargs (dict) – Additional keyword arguments passed on to func.

Returns:

reduced (Dataset) – Array with summarized data and the indicated dimension(s) removed.