cumSum
Computes the cumulative sum of values in the selected columns.
cumSum(skipNA = true) [ { columns } ]
Returns a DataFrame or DataColumn containing the cumulative sum.
See column selectors for how to select the columns for this operation.
Parameters:
skipNA— whentrue, ignoresNAvalues (nullorNaN). Whenfalse, all values after firstNAwill beNaN(forDoubleandFloatcolumns) ornull(for integer columns).
Available for:
GroupBy DataFrame— cumulative sum per every data group
df.cumSum { weight }
df.weight.cumSum()
df.groupBy { city }.cumSum { weight }.concat()
Big numbers
For a BigDecimal column amount, the exact cumulative sum can be computed with Java BigDecimal arithmetic:
// exact cumulative sum, computed with Java `BigDecimal` arithmetic
df.amount.toList().runningReduce(BigDecimal::add).toColumn("amount")
Alternatively, convert the column to a primitive type first — at the cost of precision:
// approximate cumulative sum, computed after converting the column to `Double`
df.convert { amount }.toDouble().cumSum { amount }
29 September 2026