Skip to main content
Version: Python

Create a table with time_table

This guide will show you how to create a time table. A time table is a special type of table that adds new rows at a regular, user-defined interval. Its sole column is a timestamp column.

Here, we will use the time_table method to create a simple time table that ticks every two seconds. The method's period parameter takes a duration string, which specifies the interval at which the table ticks.

Duration strings are formatted as "PTnHnMnS", where:

  • PT is the prefix to indicate a duration
  • n is a number
  • H, M, and S are the units of time (hours, minutes, and seconds, respectively)

Copy and run the following code in your console:

from deephaven import time_table

result = time_table(period="PT2S")

PT is the prefix to indicate a duration.

A time table can be told to tick starting at a specific time by using the start_time input argument. The following code block uses pandas to specify a start time that's one hour prior to the method being called. That means that when this code is run, result is initially populated with 1800 rows of data (one for every two seconds in the previous hour).

from deephaven import time_table
import pandas as pd

one_hour_earlier ="America/New_York") - pd.Timedelta(1, "hour")

result = time_table(period="PT2S", start_time=one_hour_earlier).reverse()


The examples above create append-only time tables. To create a blink time table, which only retains rows from the most recent update cycle, set the blink_table parameter to True:

from deephaven import time_table

result = time_table("PT00:00:02", blink_table=True)

This time table updates every two seconds, but only keeps the row received during the last update cycle:

Time tables are often used as trigger tables, which, through the use of snapshot_when can:

  • reduce the update frequency of ticking tables
  • create the history of a table, sampled at a regular interval