# xarray.computation.rolling.DataArrayCoarsen.reduce

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

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('5fa87993-25f5-4074-98d3-8818e27e31ab','5146996f-bdab-438a-93d7-1693a5d1232f','8119a3e3-b586-47b0-b235-66253d88906d','../lite/tree/../notebooks/index.html?path=1ff427bf_7713_42b1_aef3_a4f60582373b.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="8119a3e3-b586-47b0-b235-66253d88906d" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('5fa87993-25f5-4074-98d3-8818e27e31ab','8119a3e3-b586-47b0-b235-66253d88906d')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('5fa87993-25f5-4074-98d3-8818e27e31ab','8119a3e3-b586-47b0-b235-66253d88906d')">Open In Tab</button></div><div id="5146996f-bdab-438a-93d7-1693a5d1232f" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
