# Access Numpy Arary based on other Array

I have a numpy array A of size [2, 10]. I have another array B of length 10, whose values range between 0 and 1. I now want to access A, taking for each column the row specified by B, meaning: The output should have length 10, the i-th entry in the resulting array is A[0, i] if B[i] == 0 else A[1, i]. How do I index that correcly / most elegantly? Thanks.

S. L.
answered question

## Have an answer?

JD

`np.where(B == 0, A[0], A[1])`