-
Notifications
You must be signed in to change notification settings - Fork 174
feat: Add {Expr,Series}.any_value
#3315
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
base: main
Are you sure you want to change the base?
Conversation
{Expr, Series}.any_value{Expr,Series}.any_value
|
thanks! some initial thoughts:
|
|
Thanks @MarcoGorelli
Wouldn't using
Sure I will add such option ππΌ |
Sure, but we don't guarantee it - an in, it happens to return the first value, but it's not guaranteed (and the name Polars does something similar in joins - in the eager case it may happen to return rows in the same order when it's more efficient to do so, but it's not guaranteed (and it's documented that it's not guaranteed) |
| # !NOTE: ibis arbitrary returns a random non-null value | ||
| # See: https://ibis-project.org/reference/expression-generic.html#ibis.expr.types.generic.Column.arbitrary | ||
| expr = cast("ir.Column", expr) | ||
| return expr.arbitrary() if ignore_nulls else expr.first(include_null=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expr.first(include_null=not ignore_nulls) is not behaving as expected π«
| if kwargs.get("ignore_nulls"): | ||
| msg = ( | ||
| "`Expr.any_value(ignore_nulls=True)` is not supported in a `over` " | ||
| "context for pandas-like backend." | ||
| ) | ||
| raise NotImplementedError(msg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an issue if a group has all null values
| if last_node.kwargs.get("ignore_nulls"): | ||
| msg = ( | ||
| "`Expr.any_value(ignore_nulls=True)` is not supported in a `group_by` " | ||
| "context for pandas-like backend" | ||
| ) | ||
| raise NotImplementedError(msg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an issue if a group has all null values
What type of PR is this? (check all applicable)
Related issues
Expr.any_value?Β #3298Checklist