Skip to main content
Version: Python

partition_by

partition_by divides a single table into subtables.

Syntax

table.partition_by(by: List[str]=[])

Parameters

ParameterTypeDescription
byList[str]

The column(s) by which to group data.

Returns

A PartitionedTable containing a subtable for each group.

Examples

from deephaven import new_table
from deephaven.column import string_col, int_col

source = new_table([
string_col("X", ["A", "B", "A", "C", "B", "A", "B", "B", "C"]),
string_col("Y", ["M", "N", "O", "N", "P", "M", "O", "P", "M"]),
int_col("Number", [55, 76, 20, 130, 230, 50, 73, 137, 214]),
])

result = source.partition_by(["X"])
result1 = result.get_constituent(["A"])
result2 = result.get_constituent(["B"])
result3 = result.get_constituent(["C"])