How can I join two numpy arrays together, based on common values in each first column, or zero if no match? The arrays need not be the same length. The first column in each array represents a unique ID, and the second column is the count, both obtained from np.unique. The ultimate goal is to simply subtract the counts of each unique ID.
a = np.array([[1,2],
[3,4]])
b = np.array([[1,10],
[2,20],
[3,30]])
Desired output:
c = np.array([[1,10,2],
[2,20,0],
[3,30,4]])
cis obtained fromaandb? Your description about common values is not clear to me.recfunctions.join_bycode, there are lots of choices to deal with - the type of join, dealing with missing values, etc. A plain vanilla numpy function with the same generality would be just as fiddly.