Locked lesson.
About this lesson
Let's discuss how to use the drop function to remove a column from your data frame.
Exercise files
Download this lesson’s related exercise files.
Removing Columns.docx58.7 KB Removing Columns - Solution.docx
55.4 KB
Quick reference
Removing Columns
Removing Columns can be done temporarily or permanently.
When to use
Use these methods whenever you want to delete a column permanently or temporarily.
Instructions
To remove a column, use the drop function.
my_df.drop("Total", axis=1, inplace=True)
The first argument ("Total") is the column you want to delete.
The second argument ("axis=1") designates what to delete. Axis=1 is for columns, axis=0 is for rows.
The third argument is whether or not you want the deletion to be permanent. Inplace=True is for permanent, false is for temporary.
Hints & tips
- my_df.drop("Total", axis=1, inplace=True)
Lesson notes are only available for subscribers.