polars.Expr.struct.json_encode#
- Expr.struct.json_encode() Expr[source]#
将此结构转换为带有json值的字符串列。
示例
>>> pl.DataFrame( ... {"a": [{"a": [1, 2], "b": [45]}, {"a": [9, 1, 3], "b": None}]} ... ).with_columns(pl.col("a").struct.json_encode().alias("encoded")) shape: (2, 2) ┌──────────────────┬────────────────────────┐ │ a ┆ encoded │ │ --- ┆ --- │ │ struct[2] ┆ str │ ╞══════════════════╪════════════════════════╡ │ {[1, 2],[45]} ┆ {"a":[1,2],"b":[45]} │ │ {[9, 1, 3],null} ┆ {"a":[9,1,3],"b":null} │ └──────────────────┴────────────────────────┘