-
Notifications
You must be signed in to change notification settings - Fork 609
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
feat(api): option to include nulls in argmin
/argmax
#10193
Comments
argmin
/argmax
To answer your original question, this would be most idiomatically expressed as a groupby with In [1]: import ibis
In [2]: ibis.options.interactive = True
In [3]: t = ibis.memtable(
...: {"id": [1, 1, 1, 1, 1, 2, 2],
...: "start": [1, 2, 3, 4, 5, 10, 20],
...: "end": ['a', 'b', 'c', 'd', None, 'e', None]}
...: )
In [4]: t.group_by("id").agg(
...: start=t.start.max(),
...: end=t.end.last(order_by="start", include_null=True),
...: )
Out[4]:
┏━━━━━━━┳━━━━━━━┳━━━━━━━━┓
┃ id ┃ start ┃ end ┃
┡━━━━━━━╇━━━━━━━╇━━━━━━━━┩
│ int64 │ int64 │ string │
├───────┼───────┼────────┤
│ 2 │ 20 │ NULL │
│ 1 │ 5 │ NULL │
└───────┴───────┴────────┘ This gets the max For the actual request of supporting including NULL values in |
Thinking about this more, I think we always want to respect nulls for these functions (and treat the current
The only todo on our part then is to better document this, add a test, and fix the bad implementations. I have some workarounds in mind for duckdb and clickhouse, which I think are the only offenders here. |
@jcrist - Hmm okay I see. The reasoning makes sense to me, and I think using |
Is your feature request related to a problem?
I have a table like the following
pre-sorted by date. I want to find the latest start and thru dates of each airport like
Using
distinct()
ignores nulls:and aggregate functions like
max()
andargmax()
do not have an option to ignore nulls.What is the motivation behind your request?
No response
Describe the solution you'd like
To have a parameter
ignore_nulls
in aggregation functions likeargmax()
.What version of ibis are you running?
main
What backend(s) are you using, if any?
DuckDB
Code of Conduct
The text was updated successfully, but these errors were encountered: