Skip to main content

tytable

A small Python library that turns Polars DataFrames into Typst tables, inspired by R's tinytable package. Most of tinytable's styling power, including image/sparkline support and a Jupyter HTML preview.

Install

Install the latest release from PyPI:

uv add tytable

Or with pip:

pip install tytable

Tytable-generated .typ fragments require Typst 0.11.1 or newer to compile. The published documentation PDF is built with Typst 0.15.0.

For generated plots and sparklines, install the optional extra. Embedding existing image files with .images() needs no additional Python dependencies:

uv add "tytable[images]"

From a cloned checkout, run:

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 in a script, or let `tab` be the last line of a Jupyter cell for a preview.
tab.save("report_assets/products.typ")
tab

Rendered Product scores table

The .typ file can be #included in a Typst report and compiled as part of the whole document.

Conventions

  • Semantic row selection: non-negative i values are stable 0-based source DataFrame positions, even after row groups are inserted. Omitting i (or using i="data") selects all source rows. Use i="header", i="groupi", i="groupj", or i="all" for explicit structural selections. Styling supports every grid row. Formatting and targeted notes support data, row-group, and column-name rows; plots and images support data and row-group rows. Unsupported structural targets raise a clear error when rendered.
  • Column selection: use original DataFrame names (j="Score") or 0-based positions (j=0); display names are presentation-only.
  • Method chaining: .style(), .fmt(), .group(), and the .theme_*() methods all return self. .render() / .save() are terminal.
  • Readable defaults: text columns are left-aligned and numeric columns are right-aligned, including their headers. Explicit .style(align=...) calls override these dtype-based defaults.
  • Lazy evaluation: styling, formatting, grouping, and plotting are recorded as intent and replayed in a fixed order at render time.
  • Figure wrapping: Typst tables are figures by default, enabling captions, numbering, and labels such as label="product-scores". Use figure=False for an unnumbered table; captions and labels cannot be combined with it.

Documentation

A practical guide with rendered examples (source followed by result) from easy to complex, a task-oriented API reference, and an R-tinytable comparison table live in the PDF built from docs/main.typ:

Build locally (requires the typst CLI, install from here):

make docs
# → docs/tytable-docs.pdf

Documented public APIs remain backward compatible throughout each major release series. After version 2.0, further breaking changes are reserved for 3.0.

Coming from R tinytable

tt(df)tt(data), .style()style_tt(), .fmt()format_tt(), .group()group_tt(), and .theme_striped() / .theme_grid() correspond to 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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tytable-2.0.1.tar.gz (300.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tytable-2.0.1-py3-none-any.whl (72.3 kB view details)

Uploaded Python 3

File details

Details for the file tytable-2.0.1.tar.gz.

File metadata

  • Download URL: tytable-2.0.1.tar.gz
  • Upload date:
  • Size: 300.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for tytable-2.0.1.tar.gz
Algorithm Hash digest
SHA256 8e57cfc46dd85239a345a521cc0b8157277ed66fa91c623515044ad88a2f09c6
MD5 c3712fc90dd4a55ba2ab0717c7daf626
BLAKE2b-256 1bafd99e6548fb690fe2314f79bf7c2f77c40e0f5ace9ca6075ec4e3d28ea4f5

See more details on using hashes here.

Provenance

The following attestation bundles were made for tytable-2.0.1.tar.gz:

Publisher: release.yml on EinMaulwurf/tytable

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tytable-2.0.1-py3-none-any.whl.

File metadata

  • Download URL: tytable-2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 72.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for tytable-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d6109cb0be9a394b017552c48f09aa8e1cfa277f79e6398af4b435fcb84eb03b
MD5 f8ef1bd2bb33fda81056da518560906b
BLAKE2b-256 a74e63921a976de0b2b5cd4e0bc5065b57411f7441b17bf245a0f085b323dc2e

See more details on using hashes here.

Provenance

The following attestation bundles were made for tytable-2.0.1-py3-none-any.whl:

Publisher: release.yml on EinMaulwurf/tytable

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

3.1.0

2 files

3.0.1

2 files

3.0.0

2 files

2.2.0

2 files

2.1.0

2 files

This release

2.0.1 This release

2 files

2.0.0

2 files

1.3.0

2 files

1.2.0

2 files

1.1.0

2 files

1.0.0

2 files

0.6.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page