How to Remove a Row From a Data Frame in Pandas (Python) @DataDaft
How to Remove a Row From a Data Frame in Pandas (Python)  @DataDaft
Uploaded September 2020 | Updated November 2026, 3 hours ago
This video shows how to delete rows Data Frames in the Pandas library for Python.

If you find this video useful, like, share and subscribe to support the channel!
► Subscribe: youtube.com/c/DataDaft?sub_confirmation=1


Code used in this Python Code Clip:

import pandas as pd

import statsmodels.api as sm #(To access mtcars dataset)
mtcars = sm.datasets.get_rdataset("mtcars", "datasets", cache=True).data

mtcars.head()

# Delete rows by name with df.drop()

mtcars = mtcars.drop(["Mazda RX4 Wag"], # Rows to drop
axis = 0) # 0 for rows

mtcars.head()

# Delete rows by index

mtcars = mtcars.drop(mtcars.index[[0,2]], # Rows indicies to drop
axis = 0) # 0 for rows

mtcars.head()


* Note: YouTube does not allow greater than or less than symbols in the text description, so the code above will not be exactly the same as the code shown in the video! I will use Unicode large < and > symbols in place of the standard sized ones. .


⭐ Kite is a free AI-powered coding assistant that integrates with popular editors and IDEs to give you smart code completions and docs while you’re typing. It is a cool application of machine learning that can also help you code faster! Check it out here: kite.com/get-kite/?utm_medium=referral&utm_source=youtube&utm_campaign=datadaft&utm_content=description-only
How to Remove a Row From a Data Frame in Pandas (Python)What Is Data Science?How to Make a Scatter Plot Matrix in RHow to Detect and Fill Missing Values in Pandas (Python)Introduction to R: Chi-Squared TestsPython Programming Practice: LeetCode #17   Letter Combinations of a Phone NumberFastest To OVER 9000: Battle of the GOATsdplyr: filterPython for Data Analysis: Decision TreesPython for Data Analysis: Hypothesis Testing and T-TestsHow to Concatenate Data Frames in Pandas (Python)Kobe Bryant Shot Charts by Game Minute
DataDaft |

How to Remove a Row From a Data Frame in Pandas (Python)

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER