partition_by

partition_by partitions a table into constituent tables (also called subtables) via one or more key columns. The resultant object is called a partitioned table. A partitioned table is a table with a column containing other Deephaven tables, plus additional key columns that are used to index and access particular constituent tables. All constituent tables of a single partitioned table must have the same schema.

Syntax

Parameters

ParameterTypeDescription
byUnion[str, list[str]]

The column(s) by which to group data.

drop_keys optionalbool

Whether to drop key columns in the constituent tables. Default is False.

Returns

A PartitionedTable containing a subtable for each group.

Examples

The following example partitions a table into subtables using a single key column. After creating the partitioned table, keys is used to generate a table showing all of the unique keys in partitioned_table. Constituent tables are then grabbed by index with constituent_tables.

The following example partitions the same source table by two key columns. As a result, the keys that define partitioned_table are unique combinations of values in the X and Y columns. After source is partitioned into subtables, get_constituent is used to grab a constituent table based on its key.