Skip to content

docs: Scalar UDF Documentation #11606

@RAbraham

Description

@RAbraham

Please describe the issue

Hi,
At https://ibis-project.org/reference/scalar-udfs#ibis.expr.operations.udf.scalar.pandas, it's mentioned that I should be able to see some output when I run str_cap(t.str_col)

>>> import ibis
>>> ibis.options.interactive = True
>>> t = ibis.memtable(dict(int_col=[1, 2, 3], str_col=["a", "b", "c"]))
>>> t
┏━━━━━━━━━┳━━━━━━━━━┓
┃ int_col ┃ str_col ┃
┡━━━━━━━━━╇━━━━━━━━━┩
│ int64   │ string  │
├─────────┼─────────┤
│       1 │ a       │
│       2 │ b       │
│       3 │ c       │
└─────────┴─────────┘
>>> @ibis.udf.scalar.pandas
... def str_cap(x: str) -> str:
...     # note usage of pandas `str` method
...     return x.str.capitalize()
>>> str_cap(t.str_col)  # doctest: +SKIP
┏━━━━━━━━━━━━━━━━━━━━━━━┓
┃ string_cap_0(str_col) ┃
┡━━━━━━━━━━━━━━━━━━━━━━━┩
│ string                │
├───────────────────────┤
│ A                     │
│ B                     │
│ C                     │
└───────────────────────┘

But when I run it, I get just an expression. which when I execute with

r = str_cap(t.str_col)
r.execute()

I get an error: NotImplementedError: pandas UDFs are not supported in the <class 'sqlglot.dialects.duckdb.DuckDB'> backend

How can I test out the pandas udf? If you can show me a snippet of code, perhaps with other backends (e.g. sqlite), that'd be great.

Code of Conduct

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation related issues or PRs

    Type

    No type

    Projects

    Status

    backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions