I have the following Pandas DataFrame object df. It is a train schedule listing the date of departure, scheduled time of departure, and train company.
df
df[~df['Train'].isin(['DeutscheBahn', 'SNCF'])]
isin returns the values in df['Train'] that are in the given list, and the ~ at the beginning is essentially a not operator.
isin
df['Train']
~
not
Another working but longer syntax would be:
df[(df['Train'] != 'DeutscheBahn') & (df['Train'] != 'SNCF')]