Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: group_by multiple null columns produce phantom row #15659

Merged
merged 3 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions crates/polars-core/src/frame/group_by/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,16 @@ impl DataFrame {
.cloned()
.collect::<Vec<_>>();
if by.is_empty() {
Ok(GroupsProxy::Slice {
groups: vec![[0, self.height() as IdxSize]],
rolling: false,
Ok(if self.height() == 0 {
GroupsProxy::Slice {
groups: vec![],
ritchie46 marked this conversation as resolved.
Show resolved Hide resolved
rolling: false,
}
} else {
GroupsProxy::Slice {
groups: vec![[0, self.height() as IdxSize]],
rolling: false,
}
})
} else {
let rows = if multithreaded {
Expand Down
5 changes: 5 additions & 0 deletions py-polars/tests/unit/operations/test_group_by.py
Original file line number Diff line number Diff line change
Expand Up @@ -985,3 +985,8 @@ def test_aggregated_scalar_elementwise_15602() -> None:
)
expected = pl.DataFrame({"group": [1, 2], "foo": [[True, True], [True]]})
assert_frame_equal(out, expected)


def test_group_by_multiple_null_cols_15623() -> None:
df = pl.DataFrame(schema={"a": pl.Null, "b": pl.Null}).group_by(pl.all()).len()
assert df.is_empty()
Loading