Interactive Python tables in Quarto HTML files
[Code review] Generate beautiful, interactive reports with plain HTML.
R’s reactable and DT packages are amazing. Nothing like it in Python, but itables is start. itables is like DT in that it wraps around datatables.net. I’ll use quarto to render the table.
For advanced styling for itables, check this document out.
Here’s a basic example for itables that I’ll follow using the following `my_file.qmd` quarto markdown file:
---
title: "Data"
format:
html:
page-layout: full
embed-resources: true
smooth-scroll: true
execute:
echo: false # hides code by default
warning: false
---
```{python}
from itables import init_notebook_mode, show
init_notebook_mode(all_interactive=False)
import world_bank_data as wb
df = wb.get_countries()
df
show(df)
```
Then render with quarto.
quarto render my_file.qmd
Then this is the output (which is called `my_file.html`):
It’s got horizontal scrolling:
Boom. Combine with plotly for simple, self-contained, interactive reports using Python. Hopefully in 5 years python’s widgets will be as robust as R’s ecosystem, but this is a start.