elixir-explorer / explorer

Series (one-dimensional) and dataframes (two-dimensional) for fast and elegant data exploration in Elixir
https://hexdocs.pm/explorer
MIT License
1.12k stars 123 forks source link

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

Closed pcapel closed 8 months ago

pcapel commented 8 months ago

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 commented 8 months ago

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