Select everything but a list of columns from pandas dataframe
For completeness, you can also easily use drop
for this:
df.drop(["T1_V6"], axis=1)
Do:
df[df.columns.difference(["T1_V6"])]
Notes from comments:
This will sort the columns. If you don't want to sort call
difference
withsort=False
The
difference
won't raise error if the dropped column name doesn't exist. If you want to raise error in case the column doesn't exist then use drop as suggested in other answers:df.drop(["T1_V6"])
`