polars.LazyFrame.drop#
- LazyFrame.drop(columns: str | Sequence[str], *more_columns: str) Self [source]#
Remove columns from the dataframe.
- Parameters:
- columns
Name of the column(s) that should be removed from the dataframe.
- *more_columns
Additional columns to drop, specified as positional arguments.
Examples
Drop a single column by passing the name of that column.
>>> lf = pl.LazyFrame( ... { ... "foo": [1, 2, 3], ... "bar": [6.0, 7.0, 8.0], ... "ham": ["a", "b", "c"], ... } ... ) >>> lf.drop("ham").collect() shape: (3, 2) ┌─────┬─────┐ │ foo ┆ bar │ │ --- ┆ --- │ │ i64 ┆ f64 │ ╞═════╪═════╡ │ 1 ┆ 6.0 │ │ 2 ┆ 7.0 │ │ 3 ┆ 8.0 │ └─────┴─────┘
Drop multiple columns by passing a list of column names.
>>> lf.drop(["bar", "ham"]).collect() shape: (3, 1) ┌─────┐ │ foo │ │ --- │ │ i64 │ ╞═════╡ │ 1 │ │ 2 │ │ 3 │ └─────┘
Or use positional arguments to drop multiple columns in the same way.
>>> lf.drop("foo", "bar").collect() shape: (3, 1) ┌─────┐ │ ham │ │ --- │ │ str │ ╞═════╡ │ a │ │ b │ │ c │ └─────┘