Filtering a Dataframe Using AND

Python

In this code snippet we use "&" to include two conditions when filtering a Pandas dataframe.

Here we filter the orders dataframe where PromoID is "30_OFF" and the ProductID is 228722.

 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