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.05k stars 112 forks source link

Sorting an empty DataFrame results in a runtime Polars error #919

Open eldano opened 4 weeks ago

eldano commented 4 weeks ago

Attempting to sort a dataframe with groups and no values results in a runtime error

dataframe = DataFrame.new(a: ["a", "b", "c"])

dataframe
|> DataFrame.group_by("a")
|> DataFrame.filter(a == "d")
|> DataFrame.sort_by(a)

Output:

** (RuntimeError) Polars Error: cannot group_by + apply on empty 'DataFrame'
    (explorer 0.8.2) lib/explorer/polars_backend/shared.ex:79: Explorer.PolarsBackend.Shared.apply_dataframe/4
    #cell:2m6ajrb7ypgepmrw:3: (file)
billylanchantin commented 4 weeks ago

Thanks for the issue!

It appears this may have been an issue on the Polars side that they addressed:

But that fix was released as part of Polars 0.35 (PR 12269):

We've got a later version of Polars, so I'll have to do some more digging later.