Skip to content

Table

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

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

Styled Table from DataFrame

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