polars.Expr.str.encode#
- Expr.str.encode(encoding: TransferEncoding) Expr [source]#
Encode values using the provided encoding.
- Parameters:
- encoding{‘hex’, ‘base64’}
The encoding to use.
- Returns:
- Expr
Expression of data type
String
.
Examples
>>> df = pl.DataFrame({"strings": ["foo", "bar", None]}) >>> df.with_columns(strings_hex=pl.col("strings").str.encode("hex")) shape: (3, 2) ┌─────────┬─────────────┐ │ strings ┆ strings_hex │ │ --- ┆ --- │ │ str ┆ str │ ╞═════════╪═════════════╡ │ foo ┆ 666f6f │ │ bar ┆ 626172 │ │ null ┆ null │ └─────────┴─────────────┘