# xarray.computation.rolling.DataArrayCoarsen.reduce

#### DataArrayCoarsen.reduce(func, keep_attrs=None, \*\*kwargs)[[source]](https://github.com/pydata/xarray/blob/main/xarray/computation/rolling.py#L1413-L1449)

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

* **Parameters:**
  * **func** ([`callable()`](https://docs.python.org/3/builtins/functions.html#callable)) – Function which can be called in the form func(x, axis, \*\*kwargs)
    to return the result of collapsing an np.ndarray over the coarsening
    dimensions.  It must be possible to provide the axis argument
    with a tuple of integers.
  * **keep_attrs** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool), *default*: [`None`](https://docs.python.org/3/builtins/constants.html#None)) – If True, the attributes (`attrs`) will be copied from the original
    object to the new one. If False, the new object will be returned
    without attributes. If None uses the global default.
  * **\*\*kwargs** ([`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)) – Additional keyword arguments passed on to func.
* **Returns:**
  **reduced** ([`DataArray`](xarray.DataArray.html.md#xarray.DataArray)) – Array with summarized data.

### Examples

<div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesShowIframe('07774ad4-7980-49f2-aa0e-ed2e52f0296f','199c7131-8ed2-48a9-989f-1f1b470c45dc','5269230b-ae92-44f4-9420-66eda151e930','../lite/tree/../notebooks/index.html?path=3bcb494b_ca70_4ada_b015_4a895502b75e.ipynb','None')">Try it in your browser!</button></div>
```pycon
>>> da = xr.DataArray(np.arange(8).reshape(2, 4), dims=("a", "b"))
>>> coarsen = da.coarsen(b=2)
>>> coarsen.reduce(np.sum)
<xarray.DataArray (a: 2, b: 2)> Size: 32B
array([[ 1,  5],
       [ 9, 13]])
Dimensions without coordinates: a, b
```

<div id="5269230b-ae92-44f4-9420-66eda151e930" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('07774ad4-7980-49f2-aa0e-ed2e52f0296f','5269230b-ae92-44f4-9420-66eda151e930')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('07774ad4-7980-49f2-aa0e-ed2e52f0296f','5269230b-ae92-44f4-9420-66eda151e930')">Open In Tab</button></div><div id="199c7131-8ed2-48a9-989f-1f1b470c45dc" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
