I\'m trying to remove a group of columns from a dataset. All of the variables to remove end with the text \"prefix\".
I did manage to \"collect\' them into a group
using filter and regex
filter
regex
df.filter(regex=r'^((?!prefix).)*$')
df = pd.DataFrame(np.random.rand(2, 6), columns=['oneprefix', 'one', 'twoprefix', 'two', 'threeprefix', 'three']) df.filter(regex=r'^((?!prefix).)*$')
where:
df
All are about the same