polars.Expr.name.prefix_fields#

Expr.name.prefix_fields(prefix: str) Expr[source]#

Add a prefix to all field names of a struct.

Parameters:
prefix

Prefix to add to the field name.

Notes

This only takes effect for struct columns.

Examples

>>> df = pl.DataFrame({"x": {"a": 1, "b": 2}})
>>> df.select(pl.col("x").name.prefix_fields("prefix_")).schema
Schema({'x': Struct({'prefix_a': Int64, 'prefix_b': Int64})})