polars.Expr.struct.drop#

Expr.struct.drop(names: Sequence[str], *, strict: bool = True) Expr[source]#

Drop one or more fields from the struct.

engine:In MemoryStreamingDistributed
Parameters:
names

Names of the fields to drop.

strict

If True, raise an error if any of the specified fields do not exist in the struct.

Examples

>>> df = pl.DataFrame(
...     {
...         "aaa": [1, 2],
...         "bbb": ["ab", "cd"],
...         "ccc": [True, None],
...     }
... ).select(pl.struct("aaa", "bbb", "ccc").alias("struct_col"))
>>> df.select(pl.col("struct_col").struct.drop(["aaa"]))
shape: (2, 1)
┌─────────────┐
│ struct_col  │
│ ---         │
│ struct[2]   │
╞═════════════╡
│ {"ab",true} │
│ {"cd",null} │
└─────────────┘