You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of Polars.
Issue description
Using pl.struct in a selection context to select a column containing numpy arrays results in a
PanicException: cannot convert object to arrow
Using a pl.col instead of a pl.struct works as intended, but of course doesn't offer the features available with a pl.struct expression, such as apply in a selection context as is suggested in this stackoverflow post.
Below is a minimal reproducible example showing that pl.struct works as intended with integers and pl.col works as intended with numpy arrays but pl.struct does not work as intended with numpy arrays.
No PanicException on the last line and the ability to use the struct expression with numpy arrays together with the apply method to build a query in the selection context.
Ok, thanks for your fast answer.
I think it would be nice if this would be apparent in the documentation somewhere; right now it is not clear why storing and manipulation with pl.col works, but not with pl.struct.
Also, would it be possible to special case the basic numpy types to allow storage by pyarrow? In scientific use of python numpy is basically mandatory and ubiquitous. It would greatly facilitate interoperability I think.
I think auto-inference into a properly-typed Series on init should be quite straightforward here, given that we already convert 2D numpy arrays; the only thing preventing it from being converted above is that the data is given as a list of 1D numpy arrays. I'll take a look and confirm / create a PR if so 👍
Polars version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of Polars.
Issue description
Using
pl.struct
in a selection context to select a column containing numpy arrays results in aUsing a
pl.col
instead of apl.struct
works as intended, but of course doesn't offer the features available with apl.struct
expression, such asapply
in a selection context as is suggested in this stackoverflow post.Below is a minimal reproducible example showing that
pl.struct
works as intended with integers andpl.col
works as intended with numpy arrays butpl.struct
does not work as intended with numpy arrays.Reproducible example
Expected behavior
No
PanicException
on the last line and the ability to use the struct expression with numpy arrays together with theapply
method to build a query in the selection context.Installed versions
The text was updated successfully, but these errors were encountered: