Skip to main content
Version: Python

update_view

The update_view method creates a new table containing a new formula column for each argument.

When using update_view, the new columns are not stored in memory. Rather, a formula is stored that is used to recalculate each cell every time it is accessed.

note

The syntax for the update_view, update, and lazy_update methods is identical, as is the resulting table. update_view is recommended when:

  1. the formula is fast to compute,
  2. only a small portion of the data is being accessed,
  3. cells are accessed very few times, or
  4. memory usage must be minimized.

For other cases, consider using select, view, update, or lazy_update. These methods have different memory and computation expenses.

caution

When using view or update_view, non-deterministic methods (e.g., random numbers, current time, or mutable structures) produce unstable results. Downstream operations on these results produce undefined behavior. Non-deterministic methods should use select or update instead.

Syntax

update_view(formulas: Union[str, Sequence[str]]) -> Table

Parameters

ParameterTypeDescription
formulasUnion[str, Sequence[str]]

Formulas to compute columns in the new table; e.g., "X = A * sqrt(B)".

Returns

A new table that includes all the original columns from the source table and the newly defined formula columns.

Examples

In the following example, a new table containing the columns from the source table plus two new columns, X and Y, is created.

from deephaven import new_table
from deephaven.column import string_col, int_col

source = new_table([
string_col("A", ["The", "At", "Is", "On"]),
int_col("B", [1, 2, 3, 4]),
int_col("C", [5, 6, 7, 8])
])

result = source.update_view(formulas=["X = B", "Y = sqrt(C)"])