want to join array such that if last column of b matches first column of a then match those rows e.g row 0 in b matches with row 0 in a then join them horizontally .
a=np.array([[17., 46.],
[21., 46.],
[46., 54.]])
b=np.array([[ 3., 17.],
[12., 17.],
[ 3., 21.],
[17., 46.],
[21., 46.],
[26., 46.],
[34., 46.],
[39., 46.]])
i am doing this . it returns the index but dont know what to do next
ndx = np.searchsorted(b[:,1],a[:,0])
print(ndx) # [0 2 3]
output must be
[ 3., 17. , 17, 46.],
[12., 17. , 17, 46.],
[ 3., 21. , 21 , 46],
[17., 46. , 46 , 54],
[21., 46. , 46 , 54],
[26., 46. , 46 , 54],
[34., 46. , 46 , 54],
[39., 46. , 46 , 54]])