use_row_data
use_row_data lets you use the data of the first row of a table as a dictionary. This is useful when you want to listen to an updating table and use the data in your component.
Example
from deephaven import time_table, ui
@ui.component
def ui_table_row(table):
    row_data = ui.use_row_data(table)
    if row_data == ():
        return ui.heading("No data yet.")
    return ui.heading(f"Row data is {row_data}. Value of X is {row_data['x']}")
table_row = ui_table_row(time_table("PT1s").update("x=i").reverse())
In the above example, ui_table_row is a component that listens to a table and displays the first row of data. The row_data variable is updated every time the table updates.
Recommendations
- Use 
use_row_datafor listening to table updates: If you need to listen to a table for one row of data, useuse_row_data. - Use table operations to filter to one row: If your table has multiple rows and columns, use table operations such as 
.where,.selectand.reverseto filter to the row you want to listen to.use_row_dataalways uses the first row of the table. - Pass a Sentinel value to 
use_row_data: If you want to use a default value when the table is empty, pass a sentinel value touse_row_data. The default sentinel value isNone, which is returned when the table is empty. 
Empty tables
If the table is empty, the value of row_data will return the value of None.
from deephaven import time_table, ui
import datetime as dt
@ui.component
def ui_table_row(table):
    row_data = ui.use_row_data(table)
    if row_data is None:
        return ui.heading("No data yet.")
    return ui.heading(f"Row data: {row_data}.")
start_time = dt.datetime.now() + dt.timedelta(seconds=2)
table_row = ui_table_row(
    time_table("PT1s", start_time=start_time).update("x=i").tail(1)
)
You can optionally provide a sentinel value to return when the table is empty instead.
from deephaven import time_table, ui
import datetime as dt
@ui.component
def ui_table_row(table):
    row_data = ui.use_row_data(table, sentinel={"Timestamp": "No data yet."})
    return ui.heading(f"Row data: {row_data}. Value of 'x' is {row_data['x']}")
start_time = dt.datetime.now() + dt.timedelta(seconds=2)
table_row = ui_table_row(
    time_table("PT1s", start_time=start_time).update("x=i").tail(1)
)
Null values
If the table has a null value in the first row, the value for that cell will be pandas.NA.
from deephaven import time_table, ui
import datetime as dt
import pandas as pd
@ui.component
def ui_table_row(table):
    row_data = ui.use_row_data(table)
    if row_data is None:
        return ui.heading("No data yet.")
    if pd.isna(row_data["x"]):
        return ui.heading("Value of 'x' is null.")
    return ui.heading(f"Row data: {row_data}. Value of 'x' is {row_data['x']}")
start_time = dt.datetime.now() + dt.timedelta(seconds=2)
table_row = ui_table_row(
    time_table("PT1s", start_time=start_time).update("x=i%2==0?null:i").tail(1)
)
API reference
Return the first row of the table as a dictionary. The table should already be filtered to only have a single row.
Returns: Dict[str, Any] | Any | None The first row of the table as a dictionary or the sentinel value.
| Parameters | Type | Default | Description | 
|---|---|---|---|
| table | Table | None  | The table to extract the row from. | |
| sentinel | Any | None | The sentinel value to return if the table is ticking but empty. Defaults to None. |