xarray.DataArray.reduce¶
-
DataArray.
reduce
(func: Callable[[...], Any], dim: Union[None, Hashable, Sequence[Hashable]] = None, axis: Union[None, int, Sequence[int]] = None, keep_attrs: Optional[bool] = None, keepdims: bool = False, **kwargs) → xarray.core.dataarray.DataArray¶ Reduce this array by applying func along some dimension(s).
- Parameters
- funcfunction
Function which can be called in the form f(x, axis=axis, **kwargs) to return the result of reducing an np.ndarray over an integer valued axis.
- dimhashable or sequence of hashables, optional
Dimension(s) over which to apply func.
- axisint or sequence of int, optional
Axis(es) over which to repeatedly 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 f(x) without an axis argument).
- keep_attrsbool, optional
If True, the variable’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.
- keepdimsbool, default False
If True, the dimensions which are reduced are left in the result as dimensions of size one. Coordinates that use these dimensions are removed.
- **kwargsdict
Additional keyword arguments passed on to func.
- Returns
- reducedDataArray
DataArray with this object’s array replaced with an array with summarized data and the indicated dimension(s) removed.