Skip to content
Advertisement

How to drop a list of rows from Pandas dataframe?

I have a dataframe df :

JavaScript

Then I want to drop rows with certain sequence numbers which indicated in a list, suppose here is [1,2,4], then left:

JavaScript

How or what function can do that ?

Advertisement

Answer

Use DataFrame.drop and pass it a Series of index labels:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement