1#To delete the column without having to reassign df
2df.drop('column_name', axis=1, inplace=True)
1# Let df be a dataframe
2# Let new_df be a dataframe after dropping a column
3
4new_df = df.drop(labels='column_name', axis=1)
5
6# Or if you don't want to change the name of the dataframe
7df = df.drop(labels='column_name', axis=1)
8
9# Or to remove several columns
10df = df.drop(['list_of_column_names'], axis=1)
11
12# axis=0 for 'rows' and axis=1 for columns
1# axis=1 tells Python that we want to apply function on columns instead of rows
2# To delete the column permanently from original dataframe df, we can use the option inplace=True
3df.drop(['A', 'B', 'C'], axis=1, inplace=True)