Skip to content

DataTable

The DataTable block takes a pandas DataFrame and renders an interactive, sortable, searchable table in your report, along with advanced analysis options such as exploring data through SandDance. It supports large datasets and viewers can also download the table from the website as a CSV or Excel file.

Info

Table is the best option for displaying multidimensional DataFrames, as DataTable will flatten your data.

Simple DataTable from DataFrame

import datapane as dp
import pandas as pd
import numpy as np

df = pd.DataFrame(
    {
        "A": np.random.normal(-1, 1, 5000),
        "B": np.random.normal(1, 2, 5000),
    }
)

table = dp.DataTable(df)
report = dp.Report(table)
report.save(path="simple-datatable.html")

Running Queries on DataTable

You can run SQL queries on your datatable if you need more advanced filtering & calculations. In the previous example, if we wanted to show only the rows which had a value A > 0.5, we would write the following (note that $tbl is the builtin table name and cannot be changed):

SELECT * FROM $tbl
WHERE A > 0.5