Skip to content
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

Allow to set expression output type based on kwargs #52

Open
borchero opened this issue Dec 13, 2023 · 2 comments
Open

Allow to set expression output type based on kwargs #52

borchero opened this issue Dec 13, 2023 · 2 comments

Comments

@borchero
Copy link

borchero commented Dec 13, 2023

I'm currently experimenting with the expression plugins and, in particular, I'd like to implement a function

to_dummies(categories: list[str])

that turns a single column into a struct with the fields provided in categories.

Unfortunately, one cannot currently define the output_type of a polars_expr based on the kwargs passed to the function but only based on the input dtypes.

Rust macros are not my strong suite, unfortunately, so I can't really judge if this is feasible at all 👀

@Shoeboxam
Copy link
Contributor

I had the same need, and noticed an undocumented function output_type_func_with_kwargs that you will also find useful.

@borchero
Copy link
Author

Nice, thanks for the hint @Shoeboxam! Seems like this could, indeed, fix the issue, I'll investigate ;) in any case, it was only introduced in #62, i.e. after this issue 😜

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants