Filtering a Dataframe Using OR

Python

In this code snippet we filter to the order dataframe so that it only includes rows where either PromoID is "30_OFF" or ProductID is 228722. We do this using "|" which represent the OR operator.

 1|  orders[(orders['PromoID'] == '30_OFF') | (orders['ProductID'] == 228722)]
Did you find this snippet useful?

Sign up for free to to add this to your code library