Skip to content

Table

The Table block takes a pandas DataFrame and renders an HTML table in your app.

Info

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

Simple Table from DataFrame

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)
app = dp.App(table)
app.save(path="simple-table.html")

Styled Table from DataFrame

If your DataFrame includes DataFrame Styles, these will be included in your app. 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)

app = dp.App(
    blocks=[dp.Table(df.style.background_gradient(cmap="viridis"))]
)

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