I have a list of columns that I want to drop from a dataframe. I don't know if all the columns are present across multiple dataframes, which is why I want to iterate over them and drop the ones that are present. For example:
cols = ['one', 'two', 'three']
for col in cols:
try:
df = df.drop(col, axis=1)
except:
pass
Is there a more efficient way to do this that saves time/processing power?