Using Pythons filter to select columns in dataframe

A simple trick to select columns from a dataframe:

# Create the filter condition
condition = lambda col: col not in DESIRED_COLUMNS
# Filter the dataframe
filtered_df = df.drop(*filter(condition, df.columns))