Let x be a numeric vector. In Matlab typing:
y=1*(x>0.1)
Gives a vector of the same size as x with ones and zeros depending on whether the corresponding element in x satisfies the condition. Is there a similar short hand statement in Python (or common library) to achieve this without a loop?
>Solution :
y = [ int(z > 1) for z in x]