Delete a column from a Pandas DataFrame

Created by LondonRobLinked to 61m issues across 106 teams

tl;dr

The most efficient way to delete a column from a Pandas DataFrame is to use the drop method. To delete a column, you can use the following syntax:

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

The axis parameter specifies the axis to drop the column from. 0 is for rows and 1 is for columns.