I have set up three masks for my df
, and I want to filter out these values.
For example, some random masks:
mask1 = df['column1'].isnull()
mask2 = df['column2'] > 5
mask3 = df['column3'].str.contains('hello')
Now how do I combine these masks to filter out these values?
Is this the correct way? Using both ~
and |
?
masked_df = df[~mask1 | ~mask2 | ~mask3]
I have so many rows in my dataframe that I can't be 100% sure with manual checking to see if it's correct.