# xarray.computation.rolling.DatasetCoarsen.construct

#### DatasetCoarsen.construct(window_dim=None, keep_attrs=None, \*\*window_dim_kwargs)[[source]](https://github.com/pydata/xarray/blob/main/xarray/computation/rolling.py#L1237-L1339)

Convert this Coarsen object to a DataArray or Dataset.

The coarsening dimension is split or reshaped to two new dimensions.

* **Parameters:**
  * **window_dim** ([mapping](https://docs.python.org/3/glossary.html#term-mapping)) – A mapping from existing dimension name to new dimension names.
    The size of the second dimension will be the length of the
    coarsening window.
  * **keep_attrs** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool), *optional*) – Preserve attributes if True
  * **\*\*window_dim_kwargs** (`{dim: new_name, ...}`) – The keyword arguments form of `window_dim`.
* **Returns:**
  [`Dataset`](xarray.Dataset.html.md#xarray.Dataset) or `DataArray with reshaped dimensions`

#### SEE ALSO
[`DataArrayRolling.construct`](xarray.computation.rolling.DataArrayRolling.construct.html.md#xarray.computation.rolling.DataArrayRolling.construct), [`DatasetRolling.construct`](xarray.computation.rolling.DatasetRolling.construct.html.md#xarray.computation.rolling.DatasetRolling.construct)

### Examples

<div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesShowIframe('1d7bbcfc-79b6-4656-b6dd-ad3388110489','8de67143-3796-4f73-bf62-5069e5009463','e2062d58-160d-4331-bf81-c1d3da8f3515','../lite/tree/../notebooks/index.html?path=00b2e69a_7a3a_4158_a3dc_573022d9058c.ipynb','None')">Try it in your browser!</button></div>
```pycon
>>> da = xr.DataArray(np.arange(24), dims="time")
>>> da.coarsen(time=12).construct(time=("year", "month"))
<xarray.DataArray (year: 2, month: 12)> Size: 192B
array([[ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11],
       [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]])
Dimensions without coordinates: year, month
```

<div id="e2062d58-160d-4331-bf81-c1d3da8f3515" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('1d7bbcfc-79b6-4656-b6dd-ad3388110489','e2062d58-160d-4331-bf81-c1d3da8f3515')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('1d7bbcfc-79b6-4656-b6dd-ad3388110489','e2062d58-160d-4331-bf81-c1d3da8f3515')">Open In Tab</button></div><div id="8de67143-3796-4f73-bf62-5069e5009463" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
