polars.Expr.str.decode#

Expr.str.decode(encoding: TransferEncoding, strict: bool = False) Expr[source]#

Decode a value using the provided encoding.

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

The encoding to use.

strict

How to handle invalid inputs:

  • True: An error will be thrown if unable to decode a value.

  • False: Unhandled values will be replaced with None.

Examples

>>> df = pl.DataFrame({"encoded": ["666f6f", "626172", None]})
>>> df.select(pl.col("encoded").str.decode("hex"))
shape: (3, 1)
┌─────────┐
│ encoded │
│ ---     │
│ str     │
╞═════════╡
│ foo     │
├╌╌╌╌╌╌╌╌╌┤
│ bar     │
├╌╌╌╌╌╌╌╌╌┤
│ null    │
└─────────┘