stats.crosstab

crosstab

crosstab(data: DataInput | DataSource, column: str, *, by: str, denominator: Literal['total', 'group', 'row'] = 'group', include_null: bool = True, max_cells: int = 1000) -> pl.DataFrame

Tidy two-way counts/percentages, with explicit denominator semantics.

group means within each by category; row means within each column category. Results are deterministically sorted by string labels.

Example

table = ps.stats.crosstab(df, 'enctype', by='cohort', denominator='group')

← Statistics and diagnostics API