# xarray.DataArray.cumulative

#### DataArray.cumulative(dim, min_periods=1)[[source]](https://github.com/pydata/xarray/blob/main/xarray/core/dataarray.py#L7490-L7562)

Return an accumulating object for DataArrays.

* **Parameters:**
  * **dim** ([iterable](https://docs.python.org/3/glossary.html#term-iterable) of [hashable](../user-guide/terminology.html.md#term-name)) – The name(s) of the dimensions to create the cumulative window along
  * **min_periods** ([`int`](https://docs.python.org/3/builtins/functions.html#int), *default*: `1`) – Minimum number of observations in window required to have a value
    (otherwise result is NA). The default is 1 (note this is different
    from `Rolling`, whose default is the size of the window).
* **Returns:**
  [`computation.rolling.DataArrayRolling`](xarray.computation.rolling.DataArrayRolling.html.md#xarray.computation.rolling.DataArrayRolling)

#### SEE ALSO
[`DataArray.rolling`](xarray.DataArray.rolling.html.md#xarray.DataArray.rolling), [`Dataset.cumulative`](xarray.Dataset.cumulative.html.md#xarray.Dataset.cumulative), [`computation.rolling.DataArrayRolling`](xarray.computation.rolling.DataArrayRolling.html.md#xarray.computation.rolling.DataArrayRolling)

### Examples

<div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesShowIframe('0d3e5d5a-f636-4992-8d87-186353516605','14e133be-1fbc-429a-9899-87bdd76af5e1','79c24d00-57e4-46c3-8b37-c991d9afe124','../lite/tree/../notebooks/index.html?path=7722e4cc_543b_466e_b56d_146e363a5d53.ipynb','None')">Try it in your browser!</button></div>

Create rolling seasonal average of monthly data e.g. DJF, JFM, …, SON:

```pycon
>>> da = xr.DataArray(
...     np.linspace(0, 11, num=12),
...     coords=[
...         pd.date_range(
...             "1999-12-15",
...             periods=12,
...             freq=pd.DateOffset(months=1),
...         )
...     ],
...     dims="time",
... )
```

```pycon
>>> da
<xarray.DataArray (time: 12)> Size: 96B
array([ 0.,  1.,  2.,  3.,  4.,  5.,  6.,  7.,  8.,  9., 10., 11.])
Coordinates:
  * time     (time) datetime64[us] 96B 1999-12-15 2000-01-15 ... 2000-11-15
```

```pycon
>>> da.cumulative("time").sum()
<xarray.DataArray (time: 12)> Size: 96B
array([ 0.,  1.,  3.,  6., 10., 15., 21., 28., 36., 45., 55., 66.])
Coordinates:
  * time     (time) datetime64[us] 96B 1999-12-15 2000-01-15 ... 2000-11-15
```

<div id="79c24d00-57e4-46c3-8b37-c991d9afe124" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('0d3e5d5a-f636-4992-8d87-186353516605','79c24d00-57e4-46c3-8b37-c991d9afe124')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('0d3e5d5a-f636-4992-8d87-186353516605','79c24d00-57e4-46c3-8b37-c991d9afe124')">Open In Tab</button></div><div id="14e133be-1fbc-429a-9899-87bdd76af5e1" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
