Skip to content

Tables, Data and Big Numbers

Datapane has various blocks for adding datasets to your reports, from simple tables to interactive drilldowns.

Table

The Table component takes a pandas DataFrame and renders an HTML table in your report.

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

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

table = dp.Table(df)
report = dp.Report(table)
report.save(path="table.html")

If your DataFrame includes DataFrame Styles, these will be included in your report. DataFrame styles allows you create custom formatted tables; for instance, to show trends, highlight cells, add bar charts, or display correlations.

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

df = pd.DataFrame({"A": np.linspace(1, 10, 10)})
df = pd.concat([df, pd.DataFrame(np.random.randn(10, 4), columns=list("BCDE"))], axis=1)

report = dp.Report(
    blocks=[df.style.background_gradient(cmap="viridis")]
)

report.save("table-style.html")

Info

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

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

DataTable works for reports uploaded to Datapane.com as well as locally saved reports.

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="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

Python Dictionary & JSON

To include Python objects and JSON, we recommend using the File block.

Media and embeds

Big Number

A single number or change can often be the most important thing in a report. The BigNumbercomponent allows you to present KPIs, changes, and statistics in a friendly way to your viewers. You can optionally set intent, and pass in numbers or text.

For full reference on styling your number, see the API Documentation.

import datapane as dp

report = dp.Report(
    dp.Group(
        dp.BigNumber(
            heading="Number of percentage points",
            value="84%",
            change="2%",
            is_upward_change=True,
        ),
        dp.BigNumber(heading="Simple Statistic", value=100),
        columns=2,
    )
)

report.save(path="bignumber.html")