CumMin
CumMin
calculates a cumulative minimum in an updateBy
table operation.
Syntax
CumMin(pairs...)
Parameters
Parameter | Type | Description |
---|---|---|
pairs | String... | The column(s) to be operated on. These can include expressions to rename the output columns (e.g., |
Returns
An UpdateByOperation
to be used in an updateBy
table operation.
Examples
The following example performs an updateBy on the source
table using the CumMin
operation. No grouping columns are given, so the cumulative minimum is calculated across all rows of the table.
source = emptyTable(25).update("Letter = (i % 2 == 0) ? `A` : `B`", "X = randomInt(0, 25)")
result = source.updateBy(CumMin("MinX = X"), "Letter")
- source
- result
The following example builds on the previous by specifying Letter
as the grouping column. Thus, the cumulative minimum is calculated for each unique letter.
source = emptyTable(25).update("Letter = (i % 2 == 0) ? `A` : `B`", "X = randomInt(0, 25)")
result = source.updateBy(CumMin("MinX = X"), "Letter")
- source
- result
The following example builds on the previous by calculating the cumulative minimum of two different columns using the same UpdateByOperation
.
source = emptyTable(25).update("Letter = (i % 2 == 0) ? `A` : `B`", "X = randomInt(0, 25)", "Y = randomInt(10, 30)")
result = source.updateBy(CumMin("MinX = X", "MinY = Y"), "Letter")
- source
- result
The following example builds on the previous by grouping on two columns instead of one. Each group is defined by a unique combination of letter and boolean in the Letter
and Truth
columns, respectively.
source = emptyTable(25).update("Letter = (i % 2 == 0) ? `A` : `B`", "Truth = randomBool()", "X = randomInt(0, 25)", "Y = randomInt(10, 30)")
result = source.updateBy(CumMin("MinX = X", "MinY = Y"), "Letter", "Truth")
- source
- result