Locked lesson.
About this lesson
Deleting a row in a data frame is very similar to deleting a column - but with one small difference.
Exercise files
Download this lesson’s related exercise files.
Deleting Rows.docx57.1 KB Deleting Rows - Solution.docx
55.5 KB
Quick reference
Deleting Rows
Deleting rows is very similar to deleting columns. Use the drop() function.
When to use
Use this method to delete rows in your DataFrame.
Instructions
To delete a row named "C" from a DataFrame name my_df:
my_df.drop("C", inplace=True)
You don't have to designate an axis, because by default the 0 axis is the default axis in the drop() function, and rows are axis=0.
Hints & tips
- my_df.drop("C", inplace=True)
Lesson notes are only available for subscribers.