Skip to main content
Version: Java (Groovy)

partitionBy

partitionBy divides a single table into subtables.

Syntax

table.partitionBy(dropKeys, keyColumnNames...)
table.partitionBy(keyColumnNames...)

Parameters

ParameterTypeDescription
keyColumnNamesString...

The column(s) by which to group data.

dropKeysboolean

Whether to drop key columns in the output constituent tables.

Returns

A PartitionedTable containing a subtable for each group.

Examples

source = newTable(
stringCol("X", "A", "B", "A", "C", "B", "A", "B", "B", "C"),
stringCol("Y", "M", "N", "O", "N", "P", "M", "O", "P", "M"),
intCol("Number", 55, 76, 20, 130, 230, 50, 73, 137, 214),
)

result = source.partitionBy("X")

result1 = result.constituentFor("A")
result2 = result.constituentFor("B")
result3 = result.constituentFor("C")