0
Q:

pandas remove column

df.drop('column_name', axis=1, inplace=True)
1
df = df.drop(df.columns[[0, 1, 3]], axis=1)
1
df = df.drop(df.columns[[0, 1, 3]], axis=1)  # df.columns is zero-based pd.Index 
df.drop(['column_nameA', 'column_nameB'], axis=1, inplace=True)
0
del df['column']
1
del df['column_name'] #to remove a column from dataframe
0
del df['column_name']
0
del df['column_name']
0
To delete rows and columns from DataFrames, Pandas uses the “drop” function. To delete a column, or multiple columns, use the name of the column(s), and specify the “axis” as 1.
-1

New to Communities?

Join the community