polars.Expr.name.map_fields#
- Expr.name.map_fields(function: Callable[[str], str]) Expr [source]#
Rename fields of a struct by mapping a function over the field name.
- Parameters:
- function
Function that maps a field name to a new name.
Notes
This only take effects for struct.
Examples
>>> df = pl.DataFrame({"x": {"a": 1, "b": 2}}) >>> df.select(pl.col("x").name.map_fields(lambda x: x.upper())).schema OrderedDict({'x': Struct({'A': Int64, 'B': Int64})})