Typst tables from Polars DataFrames, with a tinytable-inspired API.
Project description
tytable
A small Python library that turns Polars DataFrames into Typst tables,
inspired by R's tinytable
package. Most of tinytable's styling power, plus image/sparkline support and a
Jupyter HTML preview.
Install
uv add git+https://github.com/EinMaulwurf/tytable.git
For development (clone and):
uv sync --all-extras
make test
Quickstart
import polars as pl
from tytable import tt
df = pl.DataFrame({
"Product": ["A", "B", "C"],
"Score": [85.43, 72.10, 91.87],
})
tab = (
tt(df, caption="Product scores", label="product-scores")
.fmt(j="Score", digits=2)
.style(j="Score", align="c")
.style(i=0, bold=True, background="#2c3e50", color="white")
.save("report_assets/products.typ")
)
# In Jupyter, let `tab` be the last line of a cell to see an HTML preview.
tab
The .typ file can be #imported into a Typst report and compiled as part of
the whole document.
Conventions
- 0-based row indexing:
i=0is the first data row (the row after the column-name header). Usei="header"for the column-name row, negative ints for column-group header rows (-1is the topmost level). - Column selection by name:
j="Score"(preferred);j=0selects the first column by position. - Method chaining:
.style(),.fmt(),.group(),.theme()all returnself..render()/.save()are terminal. - Lazy evaluation: styling, formatting, grouping, and plotting are recorded as intent and replayed in a fixed order at render time. Row indices always refer to the final, visible table.
- Figure wrapping: Typst tables are figures by default, enabling captions,
numbering, and labels such as
label="product-scores". Usefigure=Falsefor an unnumbered table; captions and labels cannot be combined with it.
Documentation
Full documentation with rendered examples (source + result side-by-side),
the complete API reference, and an R-tinytable comparison table live in the
PDF built from docs/main.typ:
- Always-current build (HEAD): https://einmaulwurf.github.io/tytable/
- Versioned (latest release): https://github.com/EinMaulwurf/tytable/releases/latest/download/tytable-docs.pdf
Build locally (requires the typst CLI):
make docs
# → docs/tytable-docs.pdf
Coming from R tinytable
tt(df) ↔ tt(data), .style() ↔ style_tt(), .fmt() ↔ format_tt(),
.group() ↔ group_tt(), .theme() ↔ theme_tt(). Indexing is 0-based
(vs R's 1-based) and columns are selected by name (preferred). The full
comparison table is in the PDF above.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tytable-0.6.0.tar.gz.
File metadata
- Download URL: tytable-0.6.0.tar.gz
- Upload date:
- Size: 231.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
36faf81dfcc811f7926f787722e46e447eb7d99ff19ab7aaf824184a689f8da4
|
|
| MD5 |
a42e5daf5bfeec0ad93808782e2ef90a
|
|
| BLAKE2b-256 |
521ecc304585f284a3c18e9539dab5256c6c881f23f8532b4bccc63b3a2c6859
|
Provenance
The following attestation bundles were made for tytable-0.6.0.tar.gz:
Publisher:
release.yml on EinMaulwurf/tytable
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tytable-0.6.0.tar.gz -
Subject digest:
36faf81dfcc811f7926f787722e46e447eb7d99ff19ab7aaf824184a689f8da4 - Sigstore transparency entry: 2169850866
- Sigstore integration time:
-
Permalink:
EinMaulwurf/tytable@2a0f13c4b6c6c3a78ee7f139e64dd0cfb64994aa -
Branch / Tag:
refs/tags/v0.6.0 - Owner: https://github.com/EinMaulwurf
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@2a0f13c4b6c6c3a78ee7f139e64dd0cfb64994aa -
Trigger Event:
push
-
Statement type:
File details
Details for the file tytable-0.6.0-py3-none-any.whl.
File metadata
- Download URL: tytable-0.6.0-py3-none-any.whl
- Upload date:
- Size: 61.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
82087d04f09805828c35d86ed33e36d8b44c43e53f01437310352bb5bfd5b03a
|
|
| MD5 |
f307d32b52a08de750aa48a1fa1c4135
|
|
| BLAKE2b-256 |
d9b548137ee447fc496e3ceb96b6aeb3b0bde430a9792f462df55e648971e049
|
Provenance
The following attestation bundles were made for tytable-0.6.0-py3-none-any.whl:
Publisher:
release.yml on EinMaulwurf/tytable
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tytable-0.6.0-py3-none-any.whl -
Subject digest:
82087d04f09805828c35d86ed33e36d8b44c43e53f01437310352bb5bfd5b03a - Sigstore transparency entry: 2169850888
- Sigstore integration time:
-
Permalink:
EinMaulwurf/tytable@2a0f13c4b6c6c3a78ee7f139e64dd0cfb64994aa -
Branch / Tag:
refs/tags/v0.6.0 - Owner: https://github.com/EinMaulwurf
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@2a0f13c4b6c6c3a78ee7f139e64dd0cfb64994aa -
Trigger Event:
push
-
Statement type: