Accumulating object for DataArrays. Parameters ---------- dims : iterable of hashable The name(s) of the dimensions to create the cumulative window along min_periods : int, default: 1 Minimum number of observations in window required
(
self,
dim: str | Iterable[Hashable],
min_periods: int = 1,
)
| 7280 | return DataArrayRolling(self, dim, min_periods=min_periods, center=center) |
| 7281 | |
| 7282 | def cumulative( |
| 7283 | self, |
| 7284 | dim: str | Iterable[Hashable], |
| 7285 | min_periods: int = 1, |
| 7286 | ) -> DataArrayRolling: |
| 7287 | """ |
| 7288 | Accumulating object for DataArrays. |
| 7289 | |
| 7290 | Parameters |
| 7291 | ---------- |
| 7292 | dims : iterable of hashable |
| 7293 | The name(s) of the dimensions to create the cumulative window along |
| 7294 | min_periods : int, default: 1 |
| 7295 | Minimum number of observations in window required to have a value |
| 7296 | (otherwise result is NA). The default is 1 (note this is different |
| 7297 | from ``Rolling``, whose default is the size of the window). |
| 7298 | |
| 7299 | Returns |
| 7300 | ------- |
| 7301 | computation.rolling.DataArrayRolling |
| 7302 | |
| 7303 | Examples |
| 7304 | -------- |
| 7305 | Create rolling seasonal average of monthly data e.g. DJF, JFM, ..., SON: |
| 7306 | |
| 7307 | >>> da = xr.DataArray( |
| 7308 | ... np.linspace(0, 11, num=12), |
| 7309 | ... coords=[ |
| 7310 | ... pd.date_range( |
| 7311 | ... "1999-12-15", |
| 7312 | ... periods=12, |
| 7313 | ... freq=pd.DateOffset(months=1), |
| 7314 | ... ) |
| 7315 | ... ], |
| 7316 | ... dims="time", |
| 7317 | ... ) |
| 7318 | |
| 7319 | >>> da |
| 7320 | <xarray.DataArray (time: 12)> Size: 96B |
| 7321 | array([ 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11.]) |
| 7322 | Coordinates: |
| 7323 | * time (time) datetime64[us] 96B 1999-12-15 2000-01-15 ... 2000-11-15 |
| 7324 | |
| 7325 | >>> da.cumulative("time").sum() |
| 7326 | <xarray.DataArray (time: 12)> Size: 96B |
| 7327 | array([ 0., 1., 3., 6., 10., 15., 21., 28., 36., 45., 55., 66.]) |
| 7328 | Coordinates: |
| 7329 | * time (time) datetime64[us] 96B 1999-12-15 2000-01-15 ... 2000-11-15 |
| 7330 | |
| 7331 | See Also |
| 7332 | -------- |
| 7333 | DataArray.rolling |
| 7334 | Dataset.cumulative |
| 7335 | computation.rolling.DataArrayRolling |
| 7336 | """ |
| 7337 | from xarray.computation.rolling import DataArrayRolling |
| 7338 | |
| 7339 | # Could we abstract this "normalize and check 'dim'" logic? It's currently shared |
nothing calls this directly
no test coverage detected