Categories
Python Answers

How to delete a column from a Python Pandas DataFrame?

Spread the love

To delete a column from a Python Pandas DataFrame, we call the drop method.

For instance, we write

df = df.drop('column_name', 1)

to call df.drop to drop the column_name column only.

The 1 indicates we drop only the column in the 1st argument.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *