polars.Series.struct.eval#
- Series.struct.eval(
- *exprs: IntoExpr | Iterable[IntoExpr],
- **named_exprs: IntoExpr,
Select fields of this struct, dropping the fields that are not selected.
This is similar to
selectonDataFrame.The expressions must be length-preserving; they are evaluated against the fields of the struct, which are addressed with
polars.field().- Parameters:
- *exprs
Field(s) to select, specified as positional arguments. Accepts expression input. Strings are parsed as column names, other non-expression inputs are parsed as literals.
- **named_exprs
Additional fields to select, specified as keyword arguments. The fields will be renamed to the keyword used.
Examples
>>> s = pl.Series("a", [{"x": 1, "y": 4}, {"x": 4, "y": 9}]) >>> s.struct.eval(pl.field("y"), x_sq=pl.field("x") ** 2) shape: (2,) Series: 'a' [struct[2]] [ {4,1} {9,16} ]