Skip to main content
1 of 2

I am wondering why no one mentions the builtin functions pandas dataframe has is similar to isin method. Here is a quick example

 df = pd.DataFrame({'cost': [250, 150, 100], 'revenue': [100, 250, 300]},index=['A', 'B', 'C']) cost revenue A 250 100 B 150 250 C 100 300 

Compare DataFrames for equality elementwise

 df=df[df["cost"].eq(250)] 

enter image description here

Compare DataFrames for greater than inequality or equality elementwise.

df=df[df["cost"].ge(100)] 

enter image description here

Compare DataFrames for strictly less than inequality elementwise.

df =df[df["cost"].lt(200)] 

enter image description here