How to drop a list of rows from a Python Pandas dataframe?

Sometimes, we want to drop a list of rows from a Python Pandas dataframe.

In this article, we’ll look at how to drop a list of rows from a Python Pandas dataframe.

How to drop a list of rows from a Python Pandas dataframe?

To drop a list of rows from a Python Pandas dataframe, we can use the data frame drop method.

For instance, we write

df.drop(df.index[[1, 3]])

to call df.drop to drop the items with index between 1 and 3 with df.index[[1, 3].

A new data frame will be returned with the rows dropped.

Conclusion

To drop a list of rows from a Python Pandas dataframe, we can use the data frame drop method.