kieferk / dfply

dplyr-style piping operations for pandas dataframes
GNU General Public License v3.0
889 stars 103 forks source link

Mask with OR #28

Closed Make42 closed 6 years ago

Make42 commented 7 years ago

When using mask() it is possible to AND statements, but I don't see a way of OR-ing statements. Could this please be added to the syntax somehow?

bleearmstrong commented 7 years ago

This already exists within mask. You just have to use parentheses with the or pipe.

df = pd.DataFrame({'x': [1, 2, 3], 'y': [4, 5, 6]})
df >> mask((X.x < 2) | (X.y > 5))
Out[24]: 
   x  y
0  1  4
2  3  6