Skip to content

How to filter array data using multiple condition? #6278

Answered by keewis
emaildipen asked this question in Q&A
Discussion options

You must be logged in to vote

the operator precedence causes python to interpret your expression as:

NT['Cloud_Mask'] == (50 & 58)

which means that it will first compute the bitwise-and of 50 and 58 (the result is 50), after which it will compare that to your array. To fix that, we need to introduce parens:

(NT['Cloud_Mask'] == 50) & (NT['Cloud_Mask'] == 58)

However, you probably want to use isin instead:

NT['Cloud_Mask'].isin([50, 58])

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by dcherian
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants