drop column from pandas dataframe code example

Example 1: drop a column pandas

df.drop(['column_1', 'Column_2'], axis = 1, inplace = True)

Example 2: drop a column from dataframe

#working with "text" syntax for the columns:
df.drop(['column_nameA', 'column_nameB'], axis=1, inplace=True)

Example 3: removing features pandas

df.drop([‘feature_1’,’feature_2’], inplace = True, axis = 1)

Example 4: how to delete a column from a dataframe in python

del df['column']

Example 5: drop columnd python

>>> df.drop(columns=['B', 'C'])
   A   D
0  0   3
1  4   7
2  8  11

Example 6: remove columns from dataframe

df.drop('col_name',1) #1 drop column / 0 drop row