How to delete a column from a data frame with pandas?

df.drop(colname, axis=1) (or del df[colname]) is the correct method to use to delete a column.

If a ValueError is raised, it means the column name is not exactly what you think it is.

Check df.columns to see what Pandas thinks are the names of the columns.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)