I want to subset the column index of a data frame, by keeping all of the columns that do NOT start with a certain string. Right now I can filter the column index for columns that start with a certain string, but I'd like to do the opposite and exclude column names that match a certain criterion.
If trying to keep the columns
If trying to keep column names that start with FR, I use this code, which works.
factor_list = df2.filter(like = 'FR_', axis=1).columns
Trying to exclude columns that start with "FR", I've tried many things including the following:
factor_list = df2.filter(like != 'FR_', axis=1).columns
factor_list = ~df2.filter(like = 'FR_', axis=1).columns