Drop a list of rows from a Pandas DataFrame
Last Updated :
15 Jul, 2025
Let us see how to drop a list of rows in a Pandas DataFrame. We can do this using the Pandas drop() function. We will also pass inplace = True and axis=0 to denote row, as it makes the changes we make in the instance stored in that instance without doing any assignment.
Creating Dataframe to drop a list of rows
Python3
# import the module
import pandas as pd
# creating a DataFrame
dictionary = {'Names': ['Simon', 'Josh', 'Amen', 'Habby',
'Jonathan', 'Nick'],
'Countries': ['AUSTRIA', 'BELGIUM', 'BRAZIL',
'FRANCE', 'INDIA', 'GERMANY']}
table = pd.DataFrame(dictionary, columns=['Names', 'Countries'],
index=['a', 'b', 'c', 'd', 'e', 'f'])
display(table)
Output:
Drop a list of rows from a Pandas DataFrame using df.drop
In this example, we are simply dropping the row with the index 3.
Python3
# drop 3rd row
display("Dropped 3rd row")
display(table.drop('c'))
Delete rows from pandas without mentioning the index labels
Here, we are simply dropping rows 1 and 3 from the Dataframe table. At first, we dropped using the index value and after that, we use the row name to drop the row.
Python3
# gives the table with the dropped rows
display("Table with the dropped rows")
display(table.drop(table.index[[1, 3]]))
# You can also use index no. instead rows name
# display(table.drop(['a', 'd']))
Output:
Drop a list of rows from a Pandas DataFrame using inplace
In this example, we are dropping the rows with and without inplace. Here, we use inplace=True which performs the drop operation in the same Dataframe, rather than creating a new Dataframe object during the drop operation.
Python3
table = pd.DataFrame(dictionary, columns=['Names', 'Countries'],
index=['a', 'b', 'c', 'd', 'e', 'f'])
# it gives none but it makes changes in the table
display(table.drop(['a', 'd'], inplace=True))
# final table
print("Final Table")
display(table)
Output:
Drop Rows by Index Range in Pandas DataFrame
The range's lower and upper limits are inclusive and exclusive, respectively. Accordingly, rows 0 and 1 will be removed, but row 2 won't be.
Python3
# table after removing range of rows from 0 to 2(not included)
table.drop(table.index[0:2], inplace=True)
display(table)
Output:
Drop Rows with Conditions in Pandas
The Josh name from the Dataframe is dropped based on the condition that if df['Names'] == 'Josh'], then drop that row. You can drop multiple rows with more conditions by following the same syntax.
Python3
df = table
index_names = df[ df['Names'] == 'Josh'].index
# drop these row indexes
# from dataFrame
df.drop(index_names, inplace = True)
display(table)
Output:
RECOMMENDED ARTICLES- How to drop rows in Pandas DataFrame by index labels?
Similar Reads
Create a list from rows in Pandas dataframe Python lists are one of the most versatile data structures, offering a range of built-in functions for efficient data manipulation. When working with Pandas, we often need to extract entire rows from a DataFrame and store them in a list for further processing. Unlike columns, which are easily access
4 min read
Create a list from rows in Pandas dataframe Python lists are one of the most versatile data structures, offering a range of built-in functions for efficient data manipulation. When working with Pandas, we often need to extract entire rows from a DataFrame and store them in a list for further processing. Unlike columns, which are easily access
4 min read
Create a list from rows in Pandas DataFrame | Set 2 In an earlier post, we had discussed some approaches to extract the rows of the dataframe as a Python's list. In this post, we will see some more methods to achieve that goal. Note : For link to the CSV file used in the code, click here. Solution #1: In order to access the data of each row of the Pa
2 min read
Create a list from rows in Pandas DataFrame | Set 2 In an earlier post, we had discussed some approaches to extract the rows of the dataframe as a Python's list. In this post, we will see some more methods to achieve that goal. Note : For link to the CSV file used in the code, click here. Solution #1: In order to access the data of each row of the Pa
2 min read
Remove last n rows of a Pandas DataFrame Let's see the various methods to Remove last n rows of a Pandas Dataframe.First, let's make a dataframe: Python3 # Import Required Libraries import pandas as pd # Create a dictionary for the dataframe dict = { 'Name': ['Sukritin', 'Sumit Tyagi', 'Akriti Goel', 'Sanskriti', 'Abhishek Jain'], 'Age': [
3 min read
Drop specific rows from multiindex Pandas Dataframe In this article, we will learn how to drop specific rows from the multi-index DataFrame. First, let us create the multi-index DataFrame. The steps are given below: Python3 import numpy as np import pandas as pd mldx_arrays = [np.array(['lion', 'lion', 'lion', 'bison', 'bison', 'bison', 'hawk', 'hawk
3 min read