Extract table values

Deephaven tables have methods to extract values from tables into Python. Generally, this isn't necessary for Deephaven queries but may be useful for debugging and logging purposes, and other specific use cases such as using listeners.

to_numpy() (positional index access)

The recommended way to extract values from a table by positional index is using to_numpy. This converts table columns to NumPy arrays, which provide positional index access.

To extract a single value by positional index, convert the column to a NumPy array and access by index:

You can also use array slicing to extract multiple values:

Warning

to_numpy copies the entire table into memory. For large tables, consider limiting table size before converting.

Important

All columns passed to to_numpy must have the same data type. For mixed types, convert columns individually.

Iterate with for loops

For iteration, you can use standard Python for loops with NumPy arrays:

For multiple columns, convert each separately or use table operations:

Advanced: ColumnSource (row key access)

For advanced use cases, you can access the underlying Java ColumnSource via .j_object. This provides access by row key, not positional index.

Important

ColumnSource methods use row keys, not positional indices. Row keys are internal identifiers that may not match positional indices, especially in filtered or modified tables.

For primitive columns, use type-specific methods:

Type-specific ColumnSource methods:

  • getInt(rowKey) for int columns
  • getLong(rowKey) for long columns
  • getDouble(rowKey) for double columns
  • getFloat(rowKey) for float columns
  • get(rowKey) for object columns

Warning

Using .j_object directly accesses the Java layer and is not idiomatic Python. Use to_numpy() for most use cases.