Getting started

Install

Install polarstory from pypi:

python -m pip install polarstory

To use the notebook explorer:

python -m pip install polarstory[notebook]

The notebook interface is optional. Automatic reports and the CLI do not require it.

Profile a parquet file

import polarstory as ps

profile = ps.profile('cohort.parquet')
profile.write_html('cohort.profile.html')

The file is scanned lazily. Many summaries are aggregations, but some exact operations still require substantial memory. Read automatic profiling for modes and cost safeguards.

Profile an existing dataframe

import polars as pl
import polarstory as ps

df = pl.DataFrame({
    'age': [34, 51, 63, None, 45],
    'enctype': ['ED', 'Inpatient', 'Outpatient', 'ED', 'Outpatient'],
    'ins_medicaid': ['N', 'Y', 'N', 'U', 'Y'],
})

ps.profile(df).write_html('example.html')

This is synthetic demonstration data. U remains a distinct category rather than automatically becoming null.

Choose a subset of variables

import polars.selectors as cs

ps.profile(df, columns=['age', 'enctype']).write_html('subset.html')
ps.profile(df, columns=cs.starts_with('ins_')).write_html('insurance.html')

Create a short report for collaborators

p = ps.profile(df)
report = ps.Report('Cohort overview')
report.add(p.summary('age'))
report.add(p.frequency('enctype'))
report.write_html('cohort_summary.html')

Open the generated HTML file in a browser, or use Print → Save as PDF.

Next steps