๐Ÿพ Xarray is now 10 years old! ๐ŸŽ‰

xarray.NamedArray.reduce

xarray.NamedArray.reduce#

NamedArray.reduce(func, dim=None, axis=None, keepdims=False, **kwargs)[source]#

Reduce this array 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 reducing 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 func is applied over all dimensions.

  • axis (int or Sequence of int, optional) โ€“ Axis(es) over which to apply func. Only one of the โ€˜dimโ€™ and โ€˜axisโ€™ arguments can be supplied. If neither are supplied, then the reduction is calculated over the flattened array (by calling func(x) without an axis argument).

  • keepdims (bool, default: False) โ€“ If True, the dimensions which are reduced are left in the result as dimensions of size one

  • **kwargs (dict) โ€“ Additional keyword arguments passed on to func.

Returns:

reduced (Array) โ€“ Array with summarized data and the indicated dimension(s) removed.