Data processing in Pandas can require various stages in between. There can be a need to drop certain rows in the datafile as well. Dropping rows in Pandas is comparatively easier when done at index level. This article explains Pandas drop row by index in easy steps.
Amy has employee data available for 10 employees. She has the file available in Python. She is looking forward to drop few rows. She is interested in droping row with index number 2,4 and 5.

Below are the key steps to drop required rows:
- Step 1: Firstly import necessary modules.
import pandas as pd
- Step 2: Then use drop function to drop the rows. Use Dataframe.index to tell Pandas which rows to drop. As we need to drop rows with index number 2,4 and 5 we will be using the below code. Please note that index start from 0. So in case the requirement is to drop row number 2 only, then we will use index option 1.
Employee_data2=Employee_data.drop(Employee_data.index[[2,4,5]])
- Step 3: Finally review the final file if it looks good. Enter the file name and press enter.
Employee_data2.head()
Thus, Amy is able to drop rows from Dataframe as per her requirement in Python. To illustrate, the above example gives good highlight of how to drop rows in Pandas by index. Pandas drop row by index in easy steps is explained well in t
To get top certifications in Python and build your resume visit here. Also, you can read books listed here to build strong knowledge around Python.
Visit us below for video tutorial:
Looking to practice more with this example? Drop us a note, we will email you the Code file:
📬 Stay Ahead in Data Science & AI – Subscribe to Newsletter!
- 🎯 Interview Series: Curated questions and answers for freshers and experienced candidates.
- 📊 Data Science for All: Simplified articles on key concepts, accessible to all levels.
- 🤖 Generative AI for All: Easy explanations on Generative AI trends transforming industries.
💡 Why Subscribe? Gain expert insights, stay ahead of trends, and prepare with confidence for your next interview.
👉 Subscribe here: