polars.Expr.str.decode#
- Expr.str.decode(encoding: TransferEncoding, *, strict: bool = True) Expr[source]#
使用提供的编码解码值。
- Parameters:
- encoding{‘hex’, ‘base64’}
使用的编码。
- strict
如果无法解码基础值,则引发错误,否则用空值屏蔽。
- Returns:
- Expr
数据类型
Binary的表达式。
示例
>>> df = pl.DataFrame({"color": ["000000", "ffff00", "0000ff"]}) >>> df.with_columns(pl.col("color").str.decode("hex").alias("decoded")) shape: (3, 2) ┌────────┬─────────────────┐ │ color ┆ decoded │ │ --- ┆ --- │ │ str ┆ binary │ ╞════════╪═════════════════╡ │ 000000 ┆ b"\x00\x00\x00" │ │ ffff00 ┆ b"\xff\xff\x00" │ │ 0000ff ┆ b"\x00\x00\xff" │ └────────┴─────────────────┘