stats.frequency¶
frequency ¶
frequency(data: DataInput | DataSource, column: str, *, top_n: int = 20, include_null: bool = True, denominator: Literal['total', 'valid'] = 'total') -> pl.DataFrame
Top frequency categories, an optional null row, and an Other remainder.
Collects only top_n grouped categories, never a full high-cardinality
frequency table. Category values are stringified for a uniform display
schema; kind distinguishes category, null, and Other rows.
Example¶
import polarstory as ps
counts = ps.stats.frequency(df, 'enctype', denominator='valid')
Research note¶
Literal codes such as 'U' remain categories, distinct from polars nulls.