SumDocs
The Sum Operation
Computes the sum of values.
All primitive number types are supported: Byte, Short, Int, Long, Float, and Double. "Mixed" Number input is supported too, as long as it consists solely of those primitive numbers; its values are then first converted to their common type using UnifiedNumberTypeOptions.PRIMITIVES_ONLY, see number unification. Big numbers (, BigInteger) are not supported; BigDecimal them to a primitive number type first.convert
null values in the input are always ignored.
If the input contains values, the result will be NaNNaN, unless skipNaN is set to true.
The result is never null and has the same type as the input, except for Byte and Short, which sum to Int, and "mixed" Number input, which sums to the common type of its values.
For more information about the resulting types: See "sum Type Conversion" on the documentation website.
Sum Modes
Depending on what exactly you want the sum of, there are several modes. They are shown here for DataFrame, but they exist for the other receivers too:
sum()— the sum of each suitable column separately.sum{ columns }— a single sum of all values in all selected columns.sumFor{ columns }— the sum of each selected column separately.sumOf{ expression }— the sum of the values that the given expression returns for each row.
Related operations:
— the sum divided by the number of values.mean— the running sum: each value plus all the values before it.cumSum
For more information: See sum on the documentation website.
For more information about unifying numbers: See "Number Unification" on the documentation website.
See all summary statistics: See "Summary statistics" on the documentation website.