Reflex Logo

Intro

Gallery

Hosting

Components

New

Learn

Components

API Reference

Onboarding

Library

/

Datadisplay

/

Datatable

The datatable component is a great way to display data in a table format. You can pass in a pandas dataframe to the data prop to create the table.

In this example we will read data from a csv file, convert it to a pandas dataframe and display it in a data_table.

We will also add a search, pagination, sorting to the data_table to make it more accessible.

import pandas as pd
nba_data = pd.read_csv("https://media.geeksforgeeks.org/wp-content/uploads/nba.csv")"""
...
rx.data_table(
    data = nba_data[["Name", "Height", "Age"]],
    pagination= True,
    search= True,
    sort= True,
)

The example below shows how to create a data table from from a list.

class State(rx.State):
    data: List = [
        ["Lionel", "Messi", "PSG"],
        ["Christiano", "Ronaldo", "Al-Nasir"],
    ]
    columns: List[str] = ["First Name", "Last Name"]


def index():
    return rx.data_table(
        data=State.data,
        columns=State.columns,
    )

A data table component.

PropTypeDescriptionValues
dataAny

The data to display. Either a list of lists or a pandas dataframe.

columnsList

The list of columns to display. Required if data is a list and should not be provided if the data field is a dataframe

searchbool

Enable a search bar.

sortbool

Enable sorting on columns.

resizablebool

Enable resizable columns.

paginationUnion

Enable pagination.

Event Triggers

See the full list of default event triggers
← DataEditorIcon →

Did you find this useful?

HomeGalleryChangelogIntroductionHosting