Is there no "join" function in numpy recarrays? I see matplotlib has something and there is a concatenate but this is not a solution. I want a fast join in numpy/scipy or understand why it is not there.
Asked
Active
Viewed 712 times
1 Answers
0
After some digging I found this slightly buried library. I think it might be doing what I need ... curious to hear other answers as well. If this is the best solution it is NOT very well documented. I'm not sure how to contribute docs:
import numpy as np
import numpy.lib.recfunctions as rfn
import numpy.random as random
a = random.randn(4,2)
b = random.randn(4,2)
a[1, 0] = 12
b[1, 0] = 12
print(a)
print(b)
a = np.rec.fromrecords(a, names='a,b')
b = np.rec.fromrecords(b, names='a,c')
print(a['a'])
print(b['a'])
c = rfn.join_by('a',a,b,jointype='outer')
print('')
print(c)

mathtick
- 6,487
- 13
- 56
- 101
-
This doesn't really work either ... you have to strip all duplicate entries somehow first. It should just check whether duplicates have the same value. – mathtick Apr 25 '12 at 20:48