Table operations overview
This page is a quick-reference index of common table operations in Deephaven. Find your task in the table, then follow the link to the operation's reference page for its syntax and examples.
These operations work on static tables and on real-time tables that tick. When the source data changes, their results update with it. A few have restrictions. range_join supports only static tables. Some operations, such as group_by, raise an error on blink tables. Aggregations on blink tables cover every row since the aggregation started, not only the current cycle's rows. See specialized semantics for blink tables.
To learn a group of operations by task, see the how-to guides:
- Filter table data
- Select and create columns
- Drop, move, and rename columns
- Sort table data
- Exact and relational joins
- Inexact, time-series, and range joins
- Group and ungroup data
- Single aggregation
- Multi-aggregation
- Rolling aggregations
- Merge tables
- Synchronize multiple tables
To choose from the aggregation operations, see Aggregations in Deephaven. To learn the concepts behind table operations, such as immutability, formula strings, and the dependency graph, see Understanding the Table API. For formulas in depth, see Formulas.
Quick reference
| I want to... | Use this |
|---|---|
| Keep rows matching a condition | where("condition") |
| Keep rows whose key values appear, or don't appear, in another table | where_in(filter_table, cols=["Key"]) / where_not_in(filter_table, cols=["Key"]) |
Get the first or last n rows | head(n) / tail(n) |
| Add columns (stored in memory) | update(["NewColumn = formula"]) |
| Add columns (computed on demand) | update_view(["NewColumn = formula"]) |
| Keep or compute specific columns (stored in memory), dropping the rest | select(["Column1", "NewColumn = formula"]) |
| Keep or compute specific columns (computed on demand), dropping the rest | view(["Column1", "NewColumn = formula"]) |
| Remove columns | drop_columns(["Column1"]) |
| Rename columns | rename_columns(["NewName = OldName"]) |
| Sort by column | sort("Column") |
| Sort in descending order | sort_descending("Column") |
| Add columns from a lookup table (at most one match per row, null if no match) | natural_join(other, on=["Key"], joins=["AddedColumn"]) |
| Add columns from a table where every row must have exactly one match | exact_join(other, on=["Key"], joins=["AddedColumn"]) |
| Join every matching row, or cross join with no key | join(other, on=["Key"]) |
| Match on a timestamp or other ordered key (closest at or before) | aj(other, on=["Key", "Timestamp"], joins=["AddedColumn"]) |
| Match on a timestamp or other ordered key (closest at or after) | raj(other, on=["Key", "Timestamp"], joins=["AddedColumn"]) |
| Group right-table values that fall in a range (static tables only) | range_join(other, on=["Key", "Start <= Timestamp <= End"], aggs=[agg.group(...)]) |
| Apply one aggregation to every non-key column, per group | sum_by(by=["Key"]) (also avg_by, max_by, min_by, and similar dedicated aggregations) |
| Count the rows in each group | count_by("Count", by=["Key"]) |
| Apply different aggregations to different columns, per group | agg_by([agg.sum_(...)], by=["Key"]) |
| Collect each group's values into arrays, or expand arrays back into rows | group_by(by=["Key"]) / ungroup() |
| Compute cumulative or rolling values | update_by([updateby.cum_sum(...)], by=["Key"]) |
| Stack tables on top of each other | merge([table1, table2]) |
Most entries are methods on a table. merge is a function.
The arguments to agg_by come from the agg module, such as agg.sum_ and agg.group. The arguments to update_by come from the updateby module, such as updateby.cum_sum. Import merge and both modules with:
Diving deeper: API references
For complete signatures, type hints, and operation contracts, see the generated API documentation:
- The Pydoc for
deephaven.table.Tablelists every Python table method with its type hints and docstring. - The Javadoc for
TableOperationsdefines the Java operations that the Python methods call.
Each operation's reference page, such as where or update, also links to its Pydoc.
A quick reference for table operations