Create a table with empty_table
This guide will show you how to create an empty, in-memory user table. Empty tables contain rows but no columns. Selection methods can be used to add columns to empty tables.
Here, we will use the empty_table
method to create a table with five rows and zero columns. The sole argument is the number of rows to be included in the new table. Copy and run the following code in your console:
from deephaven import empty_table
empty = empty_table(5)
- empty
Now you can update your table to contain data.
The examples below use the update
method to create a new column. The column type will reflect the data specified in the selection method's argument; in other words, if your data is a set of integers, an int column is created automatically.
In the following query, we add a new column (X
), which contains the same integer value (5) in each row.
result = empty.update(formulas=["X = 5"])
- result
In the following query, we create a new column (X
), which contains the values from array a
. The special variable i
is the row index.
a = [1, 2, 3, 4, 10]
result2 = empty.update(formulas=["X = (int)a[i]"])
- result2