This question is related to the following post: Replacing Numpy elements if condition is met.
Suppose i have two, one-dimensional numpy arrays a
and b
, with 50 rows each.
I would like to create an array c
of 50 rows, each of which will take the values 0-4 depending on whether a condition is met:
if a > 0 the value in the corresponding row of c should be 0
if a < 0 the value in the corresponding row of c should be 1
if a > 0 and b < 0 the value in the corresponding row of c should be 2
if b > 0 the value in the corresponding row of c should be 3
I suppose the broader question here is how can i assign specific values to an array when there are multiple conditions. I have tried variations from the post i referenced above but i have not been successful.
Any ideas of how i could achieve this, preferably without using a for-loop?