with_keys
The with_keys method returns a table that shares the underlying data and schema with the source table, but with the specified columns marked as its key columns.
Key columns are metadata used by consumers such as the Deephaven UI to identify which rows represent the same real-world entity. They do not affect the table's data. Multiple rows may share the same key column values. To additionally assert that each combination of key values identifies exactly one row, use with_unique_keys instead.
Syntax
Parameters
| Parameter | Type | Description |
|---|---|---|
| cols | Union[str, Sequence[str]] | The key column name(s). Must name at least one existing column in the source table. |
Returns
A table that shares the underlying data and schema with the source table, with the keyColumns attribute set to the specified column names. If the source table already has this exact set of key columns, the source table itself may be returned.
Examples
In this example, Key1 and Key2 together form the key column set for keyed_table. Because the same combination of values repeats across rows, selecting one of them in the Deephaven UI selects every row that shares that combination.
