# xarray.computation.rolling.DataArrayCoarsen.construct

#### DataArrayCoarsen.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('747b9d17-4925-4165-91b4-598bc9ccf0bf','c21e76c5-0fc8-4245-b988-656af81d0f28','48d31535-aae4-40c0-aac3-c187eb2fae69','../lite/tree/../notebooks/index.html?path=09220080_3dcf_43e6_82d4_19d0c44f23f3.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="48d31535-aae4-40c0-aac3-c187eb2fae69" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('747b9d17-4925-4165-91b4-598bc9ccf0bf','48d31535-aae4-40c0-aac3-c187eb2fae69')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('747b9d17-4925-4165-91b4-598bc9ccf0bf','48d31535-aae4-40c0-aac3-c187eb2fae69')">Open In Tab</button></div><div id="c21e76c5-0fc8-4245-b988-656af81d0f28" 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)
