From 8706d628ae2652c98f8fe04aa5f9b1984e883e6d Mon Sep 17 00:00:00 2001 From: ritchie Date: Sun, 30 Jun 2024 09:47:03 +0200 Subject: [PATCH] perf(python): Rechunk before groups iter --- py-polars/polars/dataframe/group_by.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py-polars/polars/dataframe/group_by.py b/py-polars/polars/dataframe/group_by.py index 0687313b844f..bce5dd09d813 100644 --- a/py-polars/polars/dataframe/group_by.py +++ b/py-polars/polars/dataframe/group_by.py @@ -100,7 +100,7 @@ def __iter__(self) -> Self: .group_by(*self.by, **self.named_by, maintain_order=self.maintain_order) .agg(F.first().agg_groups().alias(temp_col)) .collect(no_optimization=True) - ) + ).rechunk() self._group_names = groups_df.select(F.all().exclude(temp_col)).iter_rows() self._group_indices = groups_df.select(temp_col).to_series()