cf.Data.cumsum¶

Data.
cumsum
(axis=None, masked_as_zero=False, method='sequential', inplace=False)[source]¶ Return the data cumulatively summed along the given axis.
New in version 3.0.0.
 Parameters
 axis:
int
, optional Select the axis over which the cumulative sums are to be calculated. By default the cumulative sum is computed over the flattened array.
 method:
str
, optional Choose which method to use to perform the cumulative sum. See
dask.array.cumsum
for details.New in version 3.14.0.
 inplace:
bool
, optional If True then do the operation inplace and return
None
.New in version 3.3.0.
 masked_as_zero: deprecated at version 3.14.0
See the examples for the new behaviour when there are masked values.
 axis:
 Returns
Examples
>>> d = cf.Data(numpy.arange(12).reshape(3, 4)) >>> print(d.array) [[ 0 1 2 3] [ 4 5 6 7] [ 8 9 10 11]] >>> print(d.cumsum().array) [ 0 1 3 6 10 15 21 28 36 45 55 66] >>> print(d.cumsum(axis=0).array) [[ 0 1 2 3] [ 4 6 8 10] [12 15 18 21]] >>> print(d.cumsum(axis=1).array) [[ 0 1 3 6] [ 4 9 15 22] [ 8 17 27 38]]
>>> d[0, 0] = cf.masked >>> d[1, [1, 3]] = cf.masked >>> d[2, 0:2] = cf.masked >>> print(d.array) [[ 1 2 3] [4  6 ] [  10 11]] >>> print(d.cumsum(axis=0).array) [[ 1 2 3] [4  8 ] [  18 14]] >>> print(d.cumsum(axis=1).array) [[ 1 3 6] [4  10 ] [  10 21]]