# 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('67da0453-59be-4007-852c-aa77d032c4ba','e43c33a2-20d8-4064-a801-120796bae25d','caca0e9a-58e3-4331-92ac-0d3d1d7e3fc2','../lite/tree/../notebooks/index.html?path=44739b35_7ad8_4884_831e_e30a6974682d.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="caca0e9a-58e3-4331-92ac-0d3d1d7e3fc2" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('67da0453-59be-4007-852c-aa77d032c4ba','caca0e9a-58e3-4331-92ac-0d3d1d7e3fc2')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('67da0453-59be-4007-852c-aa77d032c4ba','caca0e9a-58e3-4331-92ac-0d3d1d7e3fc2')">Open In Tab</button></div><div id="e43c33a2-20d8-4064-a801-120796bae25d" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
