Pandas provide data analysts a way to delete and filter data frame using
.drop() method. Rows can be removed using index label or column name using this method.
DataFrame.drop(labels=None, axis=0, index=None, columns=None, level=None, inplace=False, errors=’raise’)
labels: String or list of strings referring row or column name.
axis: int or string value, 0 ‘index’ for Rows and 1 ‘columns’ for Columns.
index or columns: Single label or list. index or columns are an alternative to axis and cannot be used together.
level: Used to specify level in case data frame is having multiple level index.
inplace: Makes changes in original Data Frame if True.
errors: Ignores error if any value from the list doesn’t exists and drops rest of the values when errors = ‘ignore’
Return type: Dataframe with dropped values
Now, Let’s create a sample dataframe
Example #1: Delete a single Row in DataFrame by Row Index Label
Example #2: Delete Multiple Rows in DataFrame by Index Labels
Example #3: Delete a Multiple Rows by Index Position in DataFrame
Example #4: Delete rows from dataFrame in Place
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
- Python | Delete rows/columns from DataFrame using Pandas.drop()
- How to Drop Rows with NaN Values in Pandas DataFrame?
- Drop rows from Pandas dataframe with missing values or NaN in columns
- Drop a list of rows from a Pandas DataFrame
- Drop rows from the dataframe based on certain condition applied on a column
- How to Drop rows in DataFrame by conditions on column values?
- How to get rows/index names in Pandas dataframe
- Get minimum values in rows or columns with their index position in Pandas-Dataframe
- Select Rows & Columns by Name or Index in Pandas DataFrame using [ ], loc & iloc
- Convert given Pandas series into a dataframe with its index as another column on the dataframe
- Drop columns in DataFrame by label Names or by Index Positions
- How to drop one or multiple columns in Pandas Dataframe
- How to Find & Drop duplicate columns in a Pandas DataFrame?
- How to Drop Columns with NaN Values in Pandas DataFrame?
- Python | Pandas Index.drop()
- How to randomly select rows from Pandas DataFrame
- Get all rows in a Pandas DataFrame containing given substring
- Different ways to iterate over rows in Pandas Dataframe
- Selecting rows in pandas DataFrame based on conditions
- How to iterate over rows in Pandas Dataframe
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.