1 Upvote

Filtering a Dataframe Using OR

Python
Data Preprocessing

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.

orders[(orders['PromoID'] == '30_OFF') | (orders['ProductID'] == 228722)]

By analyseup - Last Updated Jan. 12, 2022, 11:55 p.m.

Did you find this snippet useful?

Sign up to bookmark this in your snippet library

COMMENTS
RELATED SNIPPETS
Pivoting Pandas Dataframes
Python
Data Preprocessing

Pandas

3
SparkSession instantiate
Python
Data Preprocessing

2
Converting Data Types
Python
Data Preprocessing

Data-cleaning

2
Data Minification
Python
Data Preprocessing

Cleaning

2
Top Contributors
75