Skip to main content

Create a table with newTable

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 intCol create a column of data. Each data column contains only one type of data, for example, int. The newTable 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.TableTools import newTable, stringCol, intCol

result = newTable(
stringCol("NameOfStringCol", "Data String 1", 'Data String 2', "Data String 3"),
intCol("NameOfIntCol", 4, 5, 6)

This produces a table with a String column, an integer column, and three rows.

We will walk you through the query step-by-step.


Python users need to import the TableTools package.

  1. We are using the newTable method. Its arguments will define our column names, types, and contents.
  2. We define a string column using the method stringCol:
    • the first argument is the column name, NameOfStringCol. 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.
  3. We define a second column using the method intCol:
    • the first argument is the column name, NameOfIntCol
    • the next arguments are the column contents, written as a comma-separated list of integers.

The TableTools class contains methods to create many different types of columns, such as:

Now that you have data in columns, it can be graphically 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.