dfply icon indicating copy to clipboard operation
dfply copied to clipboard

Can I use `%in%` operator in dfply framework?

Open rhyeu opened this issue 2 years ago • 1 comments

Can I use %in% operator in dfply framework?

here is an example.

# Import
import pandas as pd
import numpy as np
from dfply import *

# Create data frame and mask it
df  = pd.DataFrame({'a':[np.nan,2,3,4,5],'b':[6,7,8,9,np.nan],'c':[5,4,3,2,1]})

I just want to filter A with '%in%' operator, not '|' operator as follow

df >> mask(X.A %in% [2,3,4])

rhyeu avatar May 11 '22 04:05 rhyeu

you could use df >> mask(X.A.isin([2,3,4]))

economer avatar Jan 11 '24 05:01 economer