I want to use pandas filter to drop columns that contain the string "delta".
Example dataframe:
import pandas as pd
df = pd.DataFrame(dict(x=[1], x_delta=[2]))
I want to drop all the columns containing the string delta. Keep in mind that the dataframe may have many more columns, this has to be general. I'm thinking about using the filter method but I'm not being able to do the negation properly.
Thanks for your help!
This hasn't worked for me:
def not_delta(df):
"""Drop the columns that contain the word delta"""
return df.filter(regex="(?!delta)")