stats.table1¶
table1 ¶
table1(data: DataInput | DataSource, columns: list[str] | tuple[str, ...], *, by: str | None = None, numeric: Literal['median_iqr', 'mean_sd'] = 'median_iqr', percent: Literal['total', 'valid'] = 'total', include_total: bool = True, include_missing: bool = True, max_categories: int = 20, max_strata: int = 12, decimals: int = 1, variables: Variables | None = None, include_sensitive: bool = False) -> pl.DataFrame
Return a wide, formatted descriptive Table 1.
Categorical cells contain n (percent%); numeric cells contain a median
[Q1, Q3] or mean (SD) plus a nonmissing-n row. Percentages use either all
records (total) or nonmissing records (valid) in each stratum; missing
percentages always use all records. Other categories aggregates levels
outside the globally selected top max_categories.
The table is explicitly descriptive: no p-values, confidence intervals, regression, or significance tests are computed. No raw rows are collected. Sensitive variables are refused unless explicitly authorized.
Example¶
table = ps.stats.table1(
df, ['age', 'sex_admin', 'enctype'],
by='cohort', numeric='median_iqr',
)
Research note¶
The output is descriptive, without hypothesis tests or p-values; review small-cell counts.