# xarray.DataArray.cumulative

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

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)

### Examples

<div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesShowIframe('614a9deb-152d-45a8-9b4c-5ee505599e2e','d6f759eb-7c6f-4141-a872-7c042b87f628','40d900ee-0a68-4bed-b362-719d5a7ea9c6','../lite/tree/../notebooks/index.html?path=1ef10431_e57b_4700_9783_e98077207f99.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="40d900ee-0a68-4bed-b362-719d5a7ea9c6" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('614a9deb-152d-45a8-9b4c-5ee505599e2e','40d900ee-0a68-4bed-b362-719d5a7ea9c6')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('614a9deb-152d-45a8-9b4c-5ee505599e2e','40d900ee-0a68-4bed-b362-719d5a7ea9c6')">Open In Tab</button></div><div id="d6f759eb-7c6f-4141-a872-7c042b87f628" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>

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