This video shows how to delete rows Data Frames in the Pandas library for Python.

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()

Subscribe : https://www.youtube.com/channel/UCwuvoN0QKjrXUi48G_Hv7kQ

#python

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