Update: This issue is no longer present. The query produces the expected values. I ran into an issue with polars where after a groupby on a categorical variable the labels are null import polars as pl scores = pl.DataFrame({ 'zone': ['North', 'North', 'South', 'South'], 'score': [78, 39, 76, 56] }).with_columns(pl.col("zone").cast(pl.Categorical)) scores.group_by("zone").len() This produces the output below with null values for the levels. Is this expected? If so, is there a fix? Note that this doesn't happen when zone is set to a string shape: (2, 2) ┌──────┬─────┐ │ zone ┆ len │ │ --- ┆ --- │ │ cat ┆ u32 │ ╞══════╪═════╡ │ null ┆ 2 │ │ null ┆ 2 │ └──────┴─────┘ Continue reading...