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:
Expr

Expression of data type Utf8.

Examples

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