Pandas isin: Filtering rows that match multiple values

Pandas isin: Filtering rows that match multiple values

Want rows in a Python Pandas data frame that might have several values? Another way (besides the | I showed yesterday) is the “isin” method:

(
  df
  .loc[ pd.col('passenger_count').isin([5, 7]) ]
)

We’ll compare isin vs. | speed tomorrow. But I find this far more readable.