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

Add Expr.list.map_elements(func) to perform a custom function on every element in a list #16452

Open
DeflateAwning opened this issue May 23, 2024 · 2 comments
Labels
enhancement New feature or an improvement of an existing feature

Comments

@DeflateAwning
Copy link
Contributor

Description

Add Expr.list.map_elements(func) to perform a custom function on every element in a list

@DeflateAwning DeflateAwning added the enhancement New feature or an improvement of an existing feature label May 23, 2024
@cmdlineluser
Copy link
Contributor

It is accessible via list.eval()

s = pl.Series([[1, 2, 3]])

s.list.eval(   
    pl.element().map_elements(lambda n: 
        f"func({n + 1})", 
        return_dtype=pl.String
    )
)

# shape: (1,)
# Series: '' [list[str]]
# [
# 	["func(2)", "func(3)", "func(4)"]
# ]

(But probably a performance destroyer.)

@DeflateAwning
Copy link
Contributor Author

Would you consider adding it as its own method? Would make it a bit cleaner imo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or an improvement of an existing feature
Projects
None yet
Development

No branches or pull requests

2 participants