polars.internals.expr.ExprStringNameSpace.encode

ExprStringNameSpace.encode(encoding: str) polars.internals.expr.Expr

Encodes a value using the provided encoding

Parameters
encoding

‘hex’ or ‘base64’

Returns
Utf8 array with values encoded using provided encoding

Examples

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