polars
polars copied to clipboard
fix: pass scalar as series to update group information
Attempt at fix for issue https://github.com/pola-rs/polars/issues/15183.
The scalar variables are passed in as series to update groups information, which leads to panic in ac.groups(). https://github.com/pola-rs/polars/blob/252702a8c7f5c00558d2dc58460e2d9b41828917/crates/polars-lazy/src/physical_plan/expressions/apply.rs#L438
Therefore, resetting update_groups can solve this problem. Now, it works smoothly
>>> import polars as pl
>>> dfBug = (
... pl.DataFrame({"a": [1, 2, 3, 4, 5, 2, 3, 5, 1], "b": [1, 2, 3, 1, 2, 3, 1, 2, 3]})
... .group_by("a")
... .agg(pl.col.b.unique().sort().str.concat("-").str.split("-"))
... )
>>> print(dfBug)
shape: (5, 2)
┌─────┬────────────┐
│ a ┆ b │
│ --- ┆ --- │
│ i64 ┆ list[str] │
╞═════╪════════════╡
│ 1 ┆ ["1", "3"] │
│ 2 ┆ ["2", "3"] │
│ 4 ┆ ["1"] │
│ 3 ┆ ["1", "3"] │
│ 5 ┆ ["2"] │
└─────┴────────────┘
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 81.32%. Comparing base (
2fca551) to head (24911fd). Report is 4 commits behind head on main.
Additional details and impacted files
@@ Coverage Diff @@
## main #15271 +/- ##
=======================================
Coverage 81.31% 81.32%
=======================================
Files 1359 1359
Lines 176083 176077 -6
Branches 2524 2526 +2
=======================================
+ Hits 143188 143189 +1
+ Misses 32411 32404 -7
Partials 484 484
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Thanks for the PR. I will clsoe this as the bug is resolved on main.