-
Notifications
You must be signed in to change notification settings - Fork 125
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
Sorting an empty DataFrame results in a runtime Polars error #919
Comments
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. |
It could be something related with the order of the chained expressions; # ❗ doesn't work like mentioned in the issue.
df = DF.new(a: ["a", "b", "c"])
|> DF.group_by("a")
|> DF.filter(a == "d")
|> DF.sort_by(a) # ✔️ This one works
df |> DF.filter(a == "d") |> DF.sort_by(a) |> DF.group_by("a") I usually crosscheck with the python api. so; In the latest version of the api df.group_by("a").filter(pl.lit("a").eq("d")).sort("a") So my conclusion is, the order of the expressions are important. |
@ceyhunkerti I think this should still be permitted. For example: import Explorer.DataFrame
require Explorer.DataFrame
df = new(a: ["a", "a", "b"])
# Broken
df |> group_by("a") |> filter(a == "d") |> sort_by(a)
# Works
df |> lazy |> group_by("a") |> filter(a == "d") |> sort_by(a) |> compute
# #Explorer.DataFrame<
# Polars[0 x 1]
# Groups: ["a"]
# a string []
# > AFAICT Polars df.group_by("a").filter(False)
# Traceback (most recent call last):
# File "<stdin>", line 1, in <module>
# AttributeError: 'GroupBy' object has no attribute 'filter' |
Attempting to sort a dataframe with groups and no values results in a runtime error
Output:
The text was updated successfully, but these errors were encountered: