Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commite8beb5604c

README.md

core.reduce (procNode)

Fold a column to one value, or to one value per segment: sum, mean, least, greatest, count or the place of the least or greatest.

One reduce kernel run. fold names the fold. starts holds where each segment starts; the kernel then gets segments = starts.count, and without starts it folds the whole column with segments = 0.

Inputs

  • values (Column). The column folded.
  • fold (one of add, mean, min, max, count, argmin, argmax). Default "add". How the elements fold: added up, averaged, the least, the greatest, how many, or the index of the least or the greatest.
  • starts (Column<Int>, optional). Where each segment starts in the column; the fold is then one value per segment.

Outputs

  • value: the first folded element.
  • values: one element per segment (a single element without starts).
  • picked: for argmin and argmax, the chosen element's index; -1 for the other folds.

Example

local folded = g.core.reduce({ values = g.core.column({ values = { 3, 1, 2 }, type = "Float" }), fold = "max" })

folded.value is 3. With fold = "argmin", folded.value is 1 and folded.picked is 1, the place of the least.