-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Reinterpret a binary column as a fixed shape array #22126
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
Comments
I thought I might be able to work around this with some casting and reshaping, but although you can cast from Binary to List[u8], you can't cast back from a List[u8] to Binary: df.select(
pl.col('x')
.cast(pl.List(pl.UInt8))
.list.to_array(16)
.reshape((-1, 4))
.arr.to_list()
.cast(pl.Binary())
.bin.reinterpret(dtype=pl.Float32)
.reshape((-1, 4))
)
|
The List(u8) -> Binary cast was mentioned before in #21549. |
I guess that it might be more natural to support reinterpreting as a list, as the binary type is variable sized, and then you can use |
I think we should support |
I missed that there was already a PR open to implement this (the |
It seems stale. |
As mentioned in #21549 I'm working on |
The workaround in #22126 (comment) now works after #22611 was merged (thanks Itamar), although it's a bit convoluted and supporting this directly with |
Next I will take a look at #20456 and see if I can finish it up. |
Description
You can use
bin.reinterpret
to reinterpret a binary column as another type, but this is limited to scalar numeric types. It would be useful to extend this to fixed size arrays too.For example, this currently fails:
The error raised is:
The text was updated successfully, but these errors were encountered: