# 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#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('cfaccfeb-fdf0-448d-a596-7fccdf9c4c16','a537ab0e-0991-42a4-b011-c3e5ef8c38c7','32dee596-ddc1-4e82-baa7-408efb0aca63','../lite/tree/../notebooks/index.html?path=2201b3a0_12a9_4e96_942b_5ef6b88c9ffd.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="32dee596-ddc1-4e82-baa7-408efb0aca63" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('cfaccfeb-fdf0-448d-a596-7fccdf9c4c16','32dee596-ddc1-4e82-baa7-408efb0aca63')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('cfaccfeb-fdf0-448d-a596-7fccdf9c4c16','32dee596-ddc1-4e82-baa7-408efb0aca63')">Open In Tab</button></div><div id="a537ab0e-0991-42a4-b011-c3e5ef8c38c7" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
