values, inverse = np.unique(A[0], return_inverse=True)
B = np.zeros((3, len(values)))
B[0] = values
B[1, inverse[A[1] == 1]] = A[2, A[1] == 1]
B[2, inverse[A[1] == 2]] = A[2, A[1] == 2]
Convert value to row index in NumPy array