polars.DataFrame.drop#

DataFrame.drop(name: str | list[str]) DF[source]#

Remove column from DataFrame and return as new.

Parameters:
name

Column(s) to drop.

Examples

>>> df = pl.DataFrame(
...     {
...         "foo": [1, 2, 3],
...         "bar": [6.0, 7.0, 8.0],
...         "ham": ["a", "b", "c"],
...     }
... )
>>> df.drop("ham")
shape: (3, 2)
┌─────┬─────┐
│ foo ┆ bar │
│ --- ┆ --- │
│ i64 ┆ f64 │
╞═════╪═════╡
│ 1   ┆ 6.0 │
├╌╌╌╌╌┼╌╌╌╌╌┤
│ 2   ┆ 7.0 │
├╌╌╌╌╌┼╌╌╌╌╌┤
│ 3   ┆ 8.0 │
└─────┴─────┘