polars.Series.bin.decode#

Series.bin.decode(encoding: TransferEncoding, *, strict: bool = True) Series[source]#

Decode a value using the provided encoding.

Parameters:
encoding{‘hex’, ‘base64’}

The encoding to use.

strict

Raise an error if the underlying value cannot be decoded, otherwise mask out with a null value.

Examples

>>> s = pl.Series("colors", [b"000000", b"ffff00", b"0000ff"])
>>> s.bin.decode("hex")
shape: (3,)
Series: 'colors' [binary]
[
    b"\x00\x00\x00"
    b"\xff\xff\x00"
    b"\x00\x00\xff"
]
>>> s = pl.Series("colors", [b"AAAA", b"//8A", b"AAD/"])
>>> s.bin.decode("base64")
shape: (3,)
Series: 'colors' [binary]
[
    b"\x00\x00\x00"
    b"\xff\xff\x00"
    b"\x00\x00\xff"
]