Pandas Drop Rows by Index

Creating a Simple Pandas Dataframe.

Python3

# import pandas library
import pandas as pd

# dictionary with list object in values
details = {
    'Name': ['Ankit', 'Aishwarya', 'Shaurya', 'Shivangi'],
    'Age': [23, 21, 22, 21],
    'University': ['BHU', 'JNU', 'DU', 'BHU'],
}

# creating a Dataframe object
df = pd.DataFrame(details, columns=['Name', 'Age', 'University'],
                  index=['a', 'b', 'c', 'd'])

df

How to drop rows in Pandas DataFrame by index labels?

Pandas provide data analysts a way to delete and filter dataframe using the .drop() method. Rows can be removed using index labels or column names using this method. In this article, we will see how to drop rows in Pandas Dataframe by index labels.

Similar Reads

Pandas Drop Rows by Index

Creating a Simple Pandas Dataframe....

Contact Us