Skip to main content

polartableone

A polars-based implementation of the tableone library for generating summary statistics tables, often referred to as a 'Table 1'.

Features

  • Fast summary statistics for a 'Table 1' using polars
  • Automatic detection of categorical, continuous, and nonnormal variables
  • Support for stratified tables and p-values
  • Beautiful table formatting via Great Tables
  • Export to HTML, CSV, Excel, LaTeX, and many tabular formats

Differences with tableone Library

  • polars rather than pandas
  • Use of great_tables to display nicer tables.
  • In some cases, use of polars operations rather than numpy, though these are almost always identical.
  • Automatic determination of nonnormal columns and will display q1, median, q3 (whereas tableone defaults to showing mean even in these cases).
  • Specify number of bins for histograms using show_histograms=8; if show_histograms is set to True, the default is 10 bins (tableone defaults to 8)

But I Prefer tableone

Great! Just convert your polars dataframe to pandas (df.to_pandas()) and then use tableone!

Installation

pip install polartableone

Usage

import polars as pl
from polartableone import TableOne

# load your data
df = pl.read_csv('tests/datasets/pn2012.csv')

# columns to summarize
columns = ['Age', 'SysABP', 'Height', 'Weight', 'ICU', 'death']
# columns containing categorical variables
categorical = ['ICU']
# columns containing categorical variables
continuous = ['Age', 'SysABP', 'Height', 'Weight']
# non-normal variables
nonnormal = ['Age']
# limit the binary variable "death" to a single row
limit = {"death": 1}
# set the order of the categorical variables
order = {"ICU": ["MICU", "SICU", "CSRU", "CCU"]}
# set decimal places for age to 0
decimals = {"Age": 0}
# optionally, a categorical variable for stratification
groupby = 'death'
# rename the death column
labels = {'death': 'Mortality'}

# display minimum and maximum for listed variables
min_max = ['Height']

table = TableOne(df, columns=columns, categorical=categorical, continuous=continuous,
                  groupby=groupby, nonnormal=nonnormal, rename=labels, label_suffix=True,
                  decimals=decimals, limit=limit, min_max=min_max, show_histograms=True,
                  dip_test=True, normal_test=True, tukey_test=True)


# Export to CSV
table.write_csv('table1.csv')

# Export to Great Tables object for further styling
gt_table = table.to_gt()
gt_table.show()
Level Missing Overall Histogram 0 1
n 1000 864 136
Age, median [Q1,Q3] 0 68 [53,79] ▂▁▂▃▅▆▆▇▇█ 66 [53,78] 75 [62,83]
SysABP, median [Q1,Q3] 291 119.0 [102.0,137.0] ▂▁▁▁▄█▇▅▂▁ 119.0 [104.0,137.0] 115.0 [90.0,136.0]
Height, min – max 475 13.0 – 406.4 ▁▁▆▅▅▆█▅▁▁ 13.0 – 406.4 144.8 – 188.0
Weight, median [Q1,Q3] 302 80.0 [66.1,96.0] ▂▅▇█▆▃▃▂▁▁ 80.5 [66.3,96.0] 77.0 [64.8,96.7]
ICU, n (%) CCU 162 (16.2) 137 (15.9) 25 (18.4)
ICU, n (%) CSRU 202 (20.2) 194 (22.5) 8 (5.9)
ICU, n (%) MICU 380 (38.0) 318 (36.8) 62 (45.6)
ICU, n (%) SICU 256 (25.6) 215 (24.9) 41 (30.1)

Metadata

Release files for polartableone 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for polartableone 0.1.1
File Size Uploaded
polartableone-0.1.1.tar.gz 17.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for polartableone 0.1.1
File Interpreter ABI Platform
polartableone-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 30.8 kB

Release files / polartableone-0.1.1.tar.gz

Download URL polartableone-0.1.1.tar.gz
Size 17.3 kB
Tags Source
SHA-256 checksum
How to use checksums
296f2d6ff455bd57e545a9e34963809a041a94f66b4544d850e949d146006611
BLAKE2b-256 checksum
How to use checksums
93767c149cf942c1235eb3eae6e1ad0f7b2d63b220b8b47bd69050ed10f9de8f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 14, 2026.

Transparency log

Release files / polartableone-0.1.1-py3-none-any.whl

Download URL polartableone-0.1.1-py3-none-any.whl
Size 13.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
540a01184f5e69e4bc6c5e44ea58c46c64b6ab0e26e30887fafa320cf655c42e
BLAKE2b-256 checksum
How to use checksums
bc785c6b8e2c64809f2339374604fe4c0cdbb73e7af20959869905f992396133
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 14, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release 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