polars.internals.expr.ExprStringNameSpace.decode

ExprStringNameSpace.decode(encoding: str, strict: bool = False) polars.internals.expr.Expr

Decodes a value using the provided encoding

Parameters
encoding

‘hex’ or ‘base64’

strict

how to handle invalid inputs - True: method will throw error 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    │
└─────────┘