Does Python have an alternative to R's ifelse
function? That is, one-line replacement for:
b = np.random.randn()
i = ''
if b > 0:
i = 'non-negative'
elif b == 0:
i = 'zero'
else:
i = 'negative'
So it assigns a value to a variable according to the value of another variable.