polars.Expr.str.encode#

Expr.str.encode(encoding: TransferEncoding) Expr[source]#

Encode a value using the provided encoding.

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

The encoding to use.

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    │
└─────────┘