Skip to content

Table

The Table widget displays data in a structured, interactive tabular format. It supports column sorting (ascending/descending), quick filtering, and row selection for easier data exploration.

from mercury import Table

To use the Table widget, you only need to provide data. It works best with DataFrames (pandas or polars), but you can also pass lists of dict or dicts.

Example data

import pandas as pd
countries = ["Poland", "Germany", "France"]
df = pd.DataFrame({
"Country": [countries[i % 3] for i in range(100)],
"Year": [2020 + (i % 10) for i in range(100)],
"GDP": [500 + (i * 25) for i in range(100)],
})

Code

t = Table(df)

Preview

Simple Table

You can easily add more features to your table, such as row selection or filtering.

Code

t = Table(df, search=True, select_rows=True)

Preview

Table with features

After enabling row selection, you may want to access all selected rows in one place — this is very easy to do.

Code

# t is the variable that you assign the Table to
t.selected_rows

You can also customize the Table’s appearance by changing the page size (number of rows per page) or adjusting its width.

Code

t = Table(df, search=True, select_rows=True, page_size=20, width="700px")

Preview

Customized Table

type: DataFrame or list[dict] or dict

The dataset displayed in the table. Accepts pandas/polars DataFrames or standard Python structures like lists of dictionaries.

type: Integer

Sets how many rows are shown on a single page. Default is 50.

type: boolean

Enables selecting rows in the table. It’s off by default (False).

type: boolean

Enables the search bar and allows filtering table. It’s off by default (False).

type: string

Sets the width of the table component. Accepts values like 100%, 800px, or other valid CSS size units. Default is 100%.