1#To delete the column without having to reassign df
2df.drop('column_name', axis=1, inplace=True)
1df = pd.DataFrame(np.arange(12).reshape(3, 4),
2... columns=['A', 'B', 'C', 'D'])
3>>> df
4 A B C D
50 0 1 2 3
61 4 5 6 7
72 8 9 10 11
8
9Drop columns
10>>> df.drop(['B', 'C'], axis=1)
11 A D
120 0 3
131 4 7
142 8 11
15>>> df.drop(columns=['B', 'C'])
16 A D
170 0 3
181 4 7
192 8 11
1#working with "text" syntax for the columns:
2df.drop(['column_nameA', 'column_nameB'], axis=1, inplace=True)