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

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

  1. Use use_row_data for listening to table updates: If you need to listen to a table for one row of data, use use_row_data.
  2. Use table operations to filter to one row: If your table has multiple rows and columns, use table operations such as .where, .select and .reverse to filter to the row you want to listen to. use_row_data always uses the first row of the table.
  3. 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 to use_row_data. The default sentinel value is None, 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.

You can optionally provide a sentinel value to return when the table is empty instead.

Null values

If the table has a null value in the first row, the value for that cell will be pandas.NA.

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.

ParametersTypeDefaultDescription
tableTable |
None
The table to extract the row from.
sentinelAnyNoneThe sentinel value to return if the table is ticking but empty. Defaults to None.