SumDocs

internal interface SumDocs : CommonStatisticsDocs

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, BigDecimal) are not supported; convert them to a primitive number type first.

null values in the input are always ignored.

If the input contains NaN values, the result will be NaN, 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:

  • mean — the sum divided by the number of values.

  • cumSum — the running sum: each value plus all the values before it.

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.

Types

Link copied to clipboard

Selecting columns for various DataFrame operations can be done in the following ways:

Link copied to clipboard

Selecting columns for various DataFrame operations can be done in the following ways: