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: Rewrite implementation of top_k/bottom_k and fix a variety of bugs #16804

Merged
merged 7 commits into from
Jun 7, 2024

Conversation

orlp
Copy link
Collaborator

@orlp orlp commented Jun 7, 2024

This is a rewrite of our top_k and bottom_k implementations, to match our new well-defined behavior around nulls and lack of output order guarantee, and fixes a variety of bugs which were never reported, e.g.:

>>> pl.Series([1, 2, 3]).sort().bottom_k(1)
shape: (1,)
Series: '' [i64]
[
        3
]

>>> pl.Series([False, True]).bottom_k(5)
shape: (5,)
Series: '' [bool]
[
        false
        true
        true
        true
        true
]

Closes #16748.

@github-actions github-actions bot added fix Bug fix python Related to Python Polars rust Related to Rust Polars labels Jun 7, 2024
@ritchie46 ritchie46 merged commit d26b328 into pola-rs:main Jun 7, 2024
26 of 27 checks passed
@stinodego stinodego changed the title fix: rewrite top_k/bottom_k, variety of bugs fix: Rewrite implementation of top_k/bottom_k and fix a variety of bugs Jun 7, 2024
Wouittone pushed a commit to Wouittone/polars that referenced this pull request Jun 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Bug fix python Related to Python Polars rust Related to Rust Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bottom_k should not include nulls if the column contains at least k valid elements
2 participants