cf.Data.cumsum¶
-
Data.
cumsum
(axis, masked_as_zero=False)[source]¶ Return the data cumulatively summed along the given axis.
New in version 3.0.0.
See also
Parameters: Returns: Data
The data with the cumulatively summed dimension.
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(0).array) [[ 0 1 2 3] [ 4 6 8 10] [12 15 18 21]] >>> print(d.cumsum(1).array) [[ 0 1 3 6] [ 4 9 15 22] [ 8 17 27 38]] >>> d[1, 1] = cf.masked >>> print(d.array) [[0 1 2 3] [4 -- 6 7] [8 9 10 11]] >>> print(d.cumsum(1).array) [[0 1 3 6] [4 -- 10 17] [8 17 27 38]] >>> print(d.cumsum(1, masked_as_zero=True).array) [[ 0 1 3 6] [ 4 4 10 17] [ 8 17 27 38]]