Skip to content

feat: method missing in ibis/expr/types/arrays.py #10441

Open
@mercelino

Description

@mercelino

Is your feature request related to a problem?

The method mode() does not exist in the file ibis/expr/types/arrays.py, so it's not possible to apply it on a columns of arrays.
Although the method does exists in DuckDB https://duckdb.org/docs/sql/functions/list#list_-rewrite-functions

What is the motivation behind your request?

No response

Describe the solution you'd like

if i have
i would be able to do table.column.mode()
Example:
t = ibis.memtable(
... {
... "id": range(3),
... "arr": [
... [1, 2, 3, 3],
... [1, 1, 2, 2, 3, 4],
... [1, 1, 2 ,3]
... ],
... }
... )

The mode can be multiple elements, because the most frequent value in the 2 list of the column is 1 or 2, so we can pass an arguments to define if we want the min or the max

t.arr.mode('max') would give an output column arr of [3, 2, 1]
t.arr.mode('min') would give an output column arr of [3, 1, 1]
t.arr.mode() can have by default 'min' or 'max', as you want

Another option entirely different would be for the output to be a column of arrays, and then i would follow it up with the mins() or maxs() method myself

What version of ibis are you running?

9.5.0

What backend(s) are you using, if any?

DuckDB

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureFeatures or general enhancements

    Type

    No type

    Projects

    • Status

      backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions