Rows in pandas are the different cell (column) values which are aligned horizontally and also provides uniformity. Each row can have same or different value. Rows are generally marked with the index number but in pandas we can also assign index name according to the needs. In pandas, we can create, read, update and delete a column or row value. Here, we are going to learn, how to drop a list of rows from DataFrame? For this purpose, we will use pandas.DataFrame.drop() method.
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 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'
)
# or
df.drop(axis=None) # deletes a specified column.
df.drop(index=None) # deletes a specified row.
To work with pandas, we need to import pandas package first, below is the syntax:
import pandas as pd
Let us understand with the help of an example:
Output:
Now, we will drop a list of rows where index = 'B' and 'C'.
Output:

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