0

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.

kgf3JfUtW
  • 13,702
  • 10
  • 57
  • 80
mathtick
  • 6,487
  • 13
  • 56
  • 101

1 Answers1

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