DataFrame rows are based on the index values. We can manipulate both rows and columns in pandas, DataFrame.drop() method is used to delete any particular row or column based on the condition which is passed as a parameter. Here, we are going to use DataFrame.drop() to delete a row based on a column value condition.
pandas.DataFrame.drop() Method
This method is used to remove a specified row or column from the pandas DataFrame. Since rows and columns are based on index and axis values respectively, by passing the index or axis value inside DataFrame.drop() method we can delete that particular row or column. Below is the syntax:
Syntax:
DataFrame.drop(
labels=None,
axis=0,
index=None,
columns=None,
level=None,
inplace=False,
errors='raise'
)
# short forms
df.drop(axis=None) # deletes a specified column
df.drop(index=None) # deletes a specified row
To work with Python Pandas, we need to import the pandas library. Below is the syntax,
import pandas as pd
Example:
Output:

need an explanation for this answer? contact us directly to get an explanation for this answer