use_table_data
use_table_data lets you use the data of a table. 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_data is a component that listens to the last 5 rows of a table and displays the data. The table_data variable is updated every time the table updates.
Recommendations
- Use
use_table_datafor listening to table updates: If you need to listen to a table for all the data, useuse_table_data. - Use table operations to filter to the data you want: If your table has multiple rows and columns, use table operations such as
.where,.selectand.reverseto filter to the data you want to listen to. - Pass a Sentinel value to
use_table_data: If you want to use a default value when the table is empty, pass a sentinel value touse_table_data. The default sentinel value isNone, which is returned when the table is empty.
Empty tables
If the table is empty, the value of table_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 null values, they will be represented in the data with pandas.NA.
API Reference
Returns a dictionary with the contents of the table. Component will redraw if the table changes, resulting in an updated frame.
Returns: Dict[str, List[Any]] | Any The table data or the sentinel value.
| Parameters | Type | Default | Description |
|---|---|---|---|
| table | Table | None | The table to listen to. If None, None will be returned, not the sentinel value. | |
| sentinel | Any | None | The sentinel value to return if the table is ticking but empty. Defaults to None. |
| transform | Callable[[DataFrame | Any | None, bool], Any] | None | None | A function to transform the table data and is_sentinel values. Defaults to None, which will return the data as TableData. |