I have 2 ndarray:
a = np.array([[1,2], [5,0], [6,4]])
b = np.array([[1,10],[6,30], [5,20]])
I wish merge them in a array as this:
[[ 1 2 10]
[ 5 0 20]
[ 6 4 30]]
Someone knows a not iterative mode to merge 2 array by values of column 0?
I've found only this way:
import numpy as np
a = np.array([[1,2], [5,0], [6,4]])
b = np.array([[1,10],[6,30], [5,20]])
new0col = np.zeros((a.shape[0],1), dtype=int)
a = np.append(a, new0col, axis=1)
l1 = a[:,0].tolist()
l2 = b[:,0].tolist()
for i in l2:
a[l1.index(i),2] = b[l2.index(i),1]
print(a)