I would like to use df.drop(drop_list, axis=1)
to remove a number of columns from my data frame, however if an entry from drop_list
is not present in df.columns.tolist()
, the command fails, how can I prevent this from happening?
df.drop(set(drop_list) & set(df.columns), axis=1)
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments