ungroup
ungroup
ungroups column content. It is the reverse of the groupBy
method. ungroup
expands columns containing either Deephaven arrays or Java arrays.
caution
Arrays of different lengths within a row result in an error.
Syntax
table.ungroup()
table.ungroup(nullFill)
table.ungroup(nullFill, columnsToUngroup...)
table.ungroup(columnsToUngroup...)
table.ungroup(columnNames...)
Parameters
Parameter | Type | Description |
---|---|---|
columnsToUngroup | String... | The column(s) by which to ungroup data.
|
columnsToUngroup | Collection<? extends ColumnName> | The column(s) by which to ungroup data.
|
nullFill | boolean | Indicates if the ungrouped table should allow differently sized arrays and fill shorter columns with null values. If set to `false`, all arrays should be the same length. |
Returns
A new table in which array columns from the source table are expanded into separate rows.
Examples
In this example, groupBy
returns an array of values for each column, as grouped by X
. ungroup
will undo this operation and all array columns from the source table are expanded into separate rows.
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),
)
arrayTable = source.groupBy("X")
result = arrayTable.ungroup()
- source
- arrayTable
- result
In this example, groupBy
returns an array of values for each column, as grouped by X
, while ungroup
will expand the created array Y
so each element is a new row.
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),
)
arrayTable = source.groupBy("X")
result = arrayTable.ungroup("Y")
- source
- arrayTable
- result