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

Using sort_by with a grouped data frame doesn't respect nils: option #883

Closed
pcapel opened this issue Mar 20, 2024 · 1 comment · Fixed by #886
Closed

Using sort_by with a grouped data frame doesn't respect nils: option #883

pcapel opened this issue Mar 20, 2024 · 1 comment · Fixed by #886

Comments

@pcapel
Copy link
Contributor

pcapel commented Mar 20, 2024

While working with grouped data, I ran across what I believe is an issue. Grouped data doesn't appear to respect the option given to nils:

with_nil = DF.new(%{
  id: [1,1,1,2,2,2,3,3,3],
  data: [0.5, 1, nil, 0.7, 1, 0.9, 0.2, 0.2, 0.3]
})

DF.sort_by(with_nil, data, nils: :first) # works as you would expect

DF.group_by(with_nil, :id)
|> DF.sort_by(data, nils: :last) # nil value is still in the first position

Is this expected behavior, or something worth digging into further?

philss added a commit that referenced this issue Mar 21, 2024
We were using the wrong implementation for the grouped branch.

Close #883
@philss
Copy link
Member

philss commented Mar 21, 2024

Yeah, it is a bug. I implemented a fix for that. Thanks for reporting!

philss added a commit that referenced this issue Mar 22, 2024
* Fix `DF.sort_by/3` with groups to respect `:nils` option

We were using the wrong implementation for the grouped branch.

Close #883

* Improve example to show that sorting works
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 a pull request may close this issue.

2 participants