Default Settings
The simplest way to use tbl_preview() — pass a column-oriented dict and let the defaults do the work.
from great_docs import tbl_preview
from gdtest_tbl_preview import sample_scores
tbl_preview(sample_scores(20))
TableRows20Columns5 |
|
|
|
|
|
|
| 0 |
Bob |
Science |
90.8 |
B- |
True |
| 1 |
Alice |
Art |
76.2 |
A- |
True |
| 2 |
Eve |
History |
88.4 |
B- |
True |
| 3 |
Diana |
Science |
83.8 |
B- |
True |
| 4 |
Diana |
History |
72.2 |
B+ |
True |
| 15 |
Diana |
Math |
57.4 |
D |
False |
| 16 |
Iris |
Math |
44.8 |
B+ |
False |
| 17 |
Jack |
History |
54 |
B- |
False |
| 18 |
Alice |
Math |
46.1 |
A+ |
False |
| 19 |
Iris |
English |
56.7 |
B+ |
False |
From a List of Dicts
You can also pass a list of row dicts:
rows = [
{"city": "Tokyo", "pop_m": 37.4, "country": "Japan"},
{"city": "Delhi", "pop_m": 32.9, "country": "India"},
{"city": "Shanghai", "pop_m": 29.2, "country": "China"},
{"city": "São Paulo", "pop_m": 22.4, "country": "Brazil"},
{"city": "Mexico City", "pop_m": 21.8, "country": "Mexico"},
]
tbl_preview(rows)
TableRows5Columns3 |
|
|
|
|
| 0 |
Tokyo |
37.4 |
Japan |
| 1 |
Delhi |
32.9 |
India |
| 2 |
Shanghai |
29.2 |
China |
| 3 |
São Paulo |
22.4 |
Brazil |
| 4 |
Mexico City |
21.8 |
Mexico |
With a Caption
tbl_preview(
sample_scores(12),
caption="Student Performance — Fall 2025",
)
TableRows12Columns5 |
| Student Performance — Fall 2025 |
|
|
|
|
|
|
| 0 |
Bob |
Math |
67 |
B- |
True |
| 1 |
Alice |
Math |
56.7 |
F |
False |
| 2 |
Eve |
Science |
92.2 |
B |
True |
| 3 |
Diana |
Science |
85.5 |
A+ |
True |
| 4 |
Diana |
Art |
49.6 |
C |
False |
| 7 |
Iris |
Art |
52.9 |
C+ |
False |
| 8 |
Bob |
Science |
85.8 |
A |
True |
| 9 |
Jack |
Art |
46.1 |
D |
False |
| 10 |
Grace |
History |
62.8 |
B |
True |
| 11 |
Alice |
Science |
61.5 |
F |
True |