Open Yunuuuu opened 2 months ago
Struct type is not supported yet.
PRs are welcome!
I'll try to implement it.
Shorter reprex:
s = pl$Series(values = 1)$to_struct()
s$map_elements(\(x) x)
Error in .pr$Series$map_elements(self, fun, datatype, strict_return_type, :
user function panicked: map_elements
Turns out to_struct()
shouldn't be available for all Expr, only for those in the list
and arr
subnamespaces: https://docs.pola.rs/py-polars/html/search.html?q=to_struct
Doesn't solve the issue though:
library(polars)
pl$DataFrame(mtcars)$
select(pl$struct(c("mpg", "cyl"))$map_elements(\(x) x[["mpg"]]))
#> 1: user function raised an error: EvalError(lang!(function (s) { s$map_elements(f, return_type, strict_return_type, allow_fail_eval)}, ExternalPtr.set_class(["RPolarsSeries"]))
map_elements
crash forstruct
object, Here is themap_elements
document for struct in Python: https://docs.pola.rs/user-guide/expressions/user-defined-functions/#combining-multiple-column-values