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

feat: Support nulls_last option in DataFrame#sort #234

Merged
merged 3 commits into from
Jun 26, 2024

Conversation

davidgovea
Copy link
Contributor

@davidgovea davidgovea commented Jun 21, 2024

Resolves #235

The native binding for DataFrame#sort looks like:

pub fn sort(
&self,
by_column: String,
descending: bool,
nulls_last: bool,
maintain_order: bool,
) -> napi::Result<JsDataFrame> {

The LazyDataFrame variant also has the same shape.


But, the Javascript versions use a hardcoded nulls_last value of true:

return wrap("sort", arg, descending, true, maintain_order);

return wrap("sort", arg, descending, true, maintain_order);


Additionally, DataFrame#sort has a minor argument bug: maintain_order is not passed when using an options object. This bug is not present in the lazy variant.

return this.sort(arg.by, arg.descending);


So, we expose the option to the user here, and fix up the little bug.
This PR is technically breaking, since it changes the default value from nulls_last from TRUE to FALSE.
This better matches the Rust & Python versions.

@davidgovea davidgovea changed the title Expose nulls_last option in DataFrame#sort and fix minor argument bug feat: Support nulls_last option in DataFrame#sort Jun 24, 2024
Copy link
Collaborator

@universalmind303 universalmind303 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind adding a test case for the nulls_last param?

@universalmind303 universalmind303 merged commit 899a20f into pola-rs:main Jun 26, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for nulls_last sort option
2 participants