# 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#L1259-L1363)

Convert this Coarsen object to a DataArray or Dataset,
where 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`

### Examples

<div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesShowIframe('096a127e-acf2-4a70-b332-550362b61d68','3f6ce7e9-144d-4749-9bec-8f33ca884b6a','38f914b6-235a-4a4f-b70a-1ee4f13f29cf','../lite/tree/../notebooks/index.html?path=7d6ee93c_240e_4ba1_9d53_77de9aaab8cc.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="38f914b6-235a-4a4f-b70a-1ee4f13f29cf" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('096a127e-acf2-4a70-b332-550362b61d68','38f914b6-235a-4a4f-b70a-1ee4f13f29cf')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('096a127e-acf2-4a70-b332-550362b61d68','38f914b6-235a-4a4f-b70a-1ee4f13f29cf')">Open In Tab</button></div><div id="3f6ce7e9-144d-4749-9bec-8f33ca884b6a" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>

#### 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)
