Incorrect results for in-memory extrumum-by in groupby context on nested keys
Author: dsprenkelsCreated Sep 29, 2026Updated Sep 29, 2026
Labelsbugpythonneeds triage
Checks
- I have checked that this issue has not already been reported.
- I have confirmed this bug exists on the latest version of Polars.
Reproducible example
import polars as pl
lf = pl.LazyFrame({"a": [0, 0], "b": [[0], [0]]})
print(lf.group_by("a").agg(pl.col("b").min_by("b")).collect(engine="in-memory"))Log output
[:~/git/polars-3]└2 <.venv> 6e5b7b7+ ± python3 ../scratch/min_by_nested_by_streaming.py
shape: (1, 2)
┌─────┬───────────┐
│ a ┆ b │
│ --- ┆ --- │
│ i64 ┆ list[i64] │
╞═════╪═══════════╡
│ 0 ┆ null │
└─────┴───────────┘Issue description
In-memory min-by in a groupby context results an incorrect (None) result when the group-by has nested keys.
Expected behavior
[:~/git/polars-3]└2 <.venv> 6e5b7b7+ ± python3 ../scratch/min_by_nested_by_streaming.py shape: (1, 2) ┌─────┬───────────┐ │ a ┆ b │ │ --- ┆ --- │ │ i64 ┆ list[i64] │ ╞═════╪═══════════╡ │ 0 ┆ [0] │ └─────┴───────────┘
Installed versions
--------Version info---------
Polars: 2.0.0-rc.2
Build: <unknown>
Index type: UInt32
Platform: Linux-7.2.6-1-cachyos-x86_64-with-glibc2.44
Python: 3.14.7 (main, Aug 13 2026, 07:40:04) [GCC 16.2.1 20260810]
Runtime: rt32
----Optional dependencies----
Azure CLI <not installed>
adbc_driver_manager 1.12.0
altair 6.3.0
azure.identity 1.25.3
boto3 1.43.75
cloudpickle 3.1.2
connectorx 0.4.6
deltalake 1.6.6
fastexcel 0.21.0
fsspec 2026.9.0
gevent 26.9.0
google.auth 2.58.1
great_tables 1.0.0
matplotlib 3.11.2
numpy 2.5.3
openpyxl 3.1.5
pandas 3.0.6
polars_cloud 0.11.3
pyarrow 25.0.1
pydantic 2.13.5
pyiceberg 0.12.0
sqlalchemy 2.1.1
torch <not installed>
xlsx2csv 0.8.6
xlsxwriter 3.2.9Source: pola-rs/polars