# cumSum

> For the complete documentation index, see [llms.txt](https://kotlin.github.io/dataframe/llms.txt).

Computes the cumulative sum of values in the selected columns.

API reference: [cumSum](https://kotlin.github.io/dataframe/api-docs/core/org.jetbrains.kotlinx.dataframe.api/cum-sum.html)

```TEXT
cumSum(skipNA = true) [ { columns } ]
```

Returns a [DataFrame](dataframe.html) or [DataColumn](datacolumn.html) containing the cumulative sum.

See [column selectors](columnselectors.html) for how to select the columns for this operation.

Parameters:

* `skipNA` — when `true`, ignores [NA values](nanandna.html#na) (`null` or `NaN`). When `false`, all values after the first `NA` will be `NaN` (for `Double` and `Float` columns) or `null` (for integer columns).

Available for:

* [DataFrame](dataframe.html)

* [DataColumn](datacolumn.html)

* [GroupBy DataFrame](groupby.html#transformation) — cumulative sum per every data group

```KOTLIN
df.cumSum { weight }
df.weight.cumSum()
df.groupBy { city }.cumSum { weight }.concat()
```

## Big numbers

> **Warning:**
> `java.math.BigDecimal` and `java.math.BigInteger` are not supported: `cumSum` throws an exception at runtime for such columns. Compute the cumulative sum manually with Kotlin standard library methods and Java big number arithmetic, or [convert](convert.html) the column to a primitive type first.

For a `BigDecimal` column `amount`, the exact cumulative sum can be computed with Java `BigDecimal` arithmetic:

```KOTLIN
// exact cumulative sum, computed with Java `BigDecimal` arithmetic
df.amount.toList().runningReduce(BigDecimal::add).toColumn("amount")
```

Alternatively, [convert](convert.html) the column to a primitive type first — at the cost of precision:

```KOTLIN
// approximate cumulative sum, computed after converting the column to `Double`
df.convert { amount }.toDouble().cumSum { amount }
```

