Skip to main content

Emit csv-viewer's CsvGrid interactive tables from pandas DataFrames (Jupyter / Quarto / static HTML).

Project description

csv_grid

Python emitter for CsvGrid, the embeddable interactive table of the csv-viewer project: render a pandas DataFrame as a sortable, filterable, type-aware grid in Jupyter, Quarto (.qmd), or any static HTML you generate.

The grid re-infers column types from the data exactly as the viewer app does (numbers right with greater_tables-style formatting, dates ISO and centered, fzf search, equal-risk column widths). NaN / None become blank cells.

Install

uv add csv-grid              # or: pip install csv-grid

or local path install from a clone of this repo:

uv add --editable path/to/csv-viewer/python

The grid's built JS/CSS assets ship inside the package (refreshed by the repo's npm run build).

Use

from csv_grid import show, to_html

show(df)                          # Jupyter / qmd cell: display the grid
show(df, align="llrcr", fmt=[None, None, ",d", "year", ",.2f"])

html = to_html(df, name="results.df", assets="inline")   # fragment string
  • show(df, **options) displays via IPython. The JS + CSS assets are emitted once per kernel session (so once per rendered page); pass assets="inline" to force re-emission, or assets="https://…/base" to load them from a URL instead of inlining.
  • to_html(df, **options) returns an HTML fragment. The first fragment on a page should carry the assets (assets="inline" — the default — or a base URL); pass assets=False for subsequent tables.
  • payload(df) returns the {records, columns} dict the grid consumes, if you want to ship data yourself.
  • Options mirror the JS API in snake_case: global_search, column_filters, sortable, status_bar, expand_buttons, align ('llrcr…'), formats/fmt (per-column [,][.N](f|d|%|e|s), 'year', 'eng', None = auto), width_mode ('equal-risk' default, or 'coverage' to maximize the count of fully-shown cells), rows (cap the viewport to ~N rows, vertical scroll for the rest) / max_height (raw CSS, e.g. '400px'), render_cap, eager_cells, worker (default False — data is inlined), plus name (status line) and index (include the DataFrame index as leading columns). Dark mode follows the host page (prefers-color-scheme; JupyterLab dark themes included).

Dates are emitted ISO (yyyy-mm-dd, with hh:mm only when a column has non-midnight times); integral float columns are emitted as integers so the grid's integer/year rules apply.

Project details


Download files

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

Source Distribution

csv_grid-3.3.0.tar.gz (34.0 kB view details)

Uploaded Source

Built Distribution

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

csv_grid-3.3.0-py3-none-any.whl (20.3 kB view details)

Uploaded Python 3

File details

Details for the file csv_grid-3.3.0.tar.gz.

File metadata

  • Download URL: csv_grid-3.3.0.tar.gz
  • Upload date:
  • Size: 34.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for csv_grid-3.3.0.tar.gz
Algorithm Hash digest
SHA256 2ed5a4ab2bfa3d5afee24b5d1cb7ee380659aa89cd8200dd99210c23526de7b7
MD5 7dbd0b4ba6d2a712cd0fb30e16a9c51c
BLAKE2b-256 d7bb79808c1c0d7665b5b107a4cce08f64f816139550a5b0a978384770a869ec

See more details on using hashes here.

File details

Details for the file csv_grid-3.3.0-py3-none-any.whl.

File metadata

  • Download URL: csv_grid-3.3.0-py3-none-any.whl
  • Upload date:
  • Size: 20.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for csv_grid-3.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 deb4c34c4982e4a625ccdb97da821d2db9f986012d4b1106261777f88086885a
MD5 5ea981dc41debf57569ac0c64a6e399b
BLAKE2b-256 a085e017d1dc4d78964baae6121a4c0c880f603c8cfeb24bfde0949c4028ffe0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page