Skip to main content
Version: Python

Create tables from scratch with new_table

new_table

Columns are created using the following methods:

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

result = new_table(
[
int_col("IntegerColumn", [1, 2, 3]),
string_col("Strings", ["These", "are", "Strings"]),
]
)

Query language formulas

from deephaven import new_table
from deephaven.column import int_col

var = 3


def f(a, b):
return a + b


source = new_table([int_col("A", [1, 2, 3, 4, 5]), int_col("B", [10, 20, 30, 40, 50])])

result = source.update(formulas=["X = A + 3 * sqrt(B) + var + (int)f(A, B)"])

Array columns

from deephaven.column import InputColumn
from deephaven import new_table
from deephaven import dtypes
import numpy as np

int_array = dtypes.array(dtypes.int32, np.array([1, 2, 3], dtype=np.int32))
int_array_col = InputColumn("IntArrayCol", dtypes.int32_array, input_data=[int_array])

source = new_table([int_array_col])

Create new columns in a table

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

scores = new_table(
[
string_col("Name", ["James", "Lauren", "Zoey"]),
int_col("Math", [95, 72, 100]),
int_col("Science", [100, 78, 98]),
int_col("Art", [90, 92, 96]),
]
)

total = scores.update(formulas=["Total = Math + Science + Art"])
average = scores.update(formulas=["Average = (Math + Science + Art) / 3 "])