Is it possible to write an IF (threshold) using parallel computing (vector operations)?

I’d like to ask if it is possible in python to use vector operations to do:
p = np.zeros(m)
for i in range(m):
if(e[i] >= 0.9):
p[i] = 1
p[i] = 0

Something like that maybe (except in a way that would work?)
np.where(e >= 0.9, p = 1, p = 0)


(I changed variable name in case someone was going to use it in the final assignment as an answer)
Linked question (vector operation on 2d arr vs 1d) Is it possible to write all loops as vector operation? - #2 by TMosh


it’s totally fine to do that actually it’s better to do it in a NumPy way as it will be faster.
another way to do it is like this

## this will create an array of True, and False
##   and just cast it as int will result in 0, 1
result = (e > 0.9).astype(np.int64)
1 Like