numpy “TypeError: ufunc ‘bitwise_and’ not supported for the input types” when using a dynamically created boolean mask

& has higher precedence than ==, so the expression

a == 2.0 & b

is the same as

a == (2.0 & b)

You get the error because bitwise and is not defined for a floating point scalar and a boolean array.

Add parentheses to get what you expected:

(a == 2.0) & b

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)