Create a table with new_table
This guide will show you how to create a new, in-memory user table.
Deephaven stores data in tables, which are composed of rows and columns of data. Methods such as int_col
create a column of data. Each data column contains only one type of data, for example, int
. The new_table
method creates a new table from one or more data columns.
Here, we will make a simple two-column table. Copy and run the following code in your console:
from deephaven import new_table
from deephaven.column import string_col, int_col
result = new_table([
string_col("Name_Of_String_Col", ["Data String 1", 'Data String 2', "Data String 3"]),
int_col("Name_Of_Int_Col", [4, 5, 6])
])
- result
This produces a table with a String column, an integer column, and three rows.
We will walk you through the query step-by-step.
- We are using the
new_table
method. Its arguments will define our column names, types, and contents. - We define a string column using the method
string_col
:- the first argument is the column name,
Name_Of_String_Col
. Column names are typically capitalized. - the next arguments are the column contents, written as a comma-separated list. Since these are String values, they are enclosed in quotation marks.
- the first argument is the column name,
- We define a second column using the method
int_col
:- the first argument is the column name,
Name_Of_Int_Col
- the next arguments are the column contents, written as a comma-separated list of integers.
- the first argument is the column name,
Now that you have data in columns, it can be manipulated in several ways in the UI. For instance, right-clicking a column header or the table data opens menus with options to filter, sort, and copy content.