title: Merging two NumPy 2D array
body: <p>I am trying to merge/join two numpy array based on some column in the most time-efficient way.</p>
  
  <p>Here are my two numpy arrays:</p>
  
  <pre><code>import numpy as np
  
  a1 = np.array([('a', 4.672, 0.999),
     ('b', 2.24, 0.999),
     ('c', 1.984, 0.9001),])
  
  a2 = np.array([('a', 4.67),
     ('c', 2.24)])
  </code></pre>
  
  <p>Here is my function to return <strong>an array of size a1's rows of indices matching on a2's first column</strong>. I use this later to make an array of equal size and concatenate. So I need <code>[0, -, 1]</code> for a1 which gives the index of matching rows of a2.</p>
  
  <pre><code>def find_indices(x, y):
      x = x[:, 0]
      y = y[:, 0]
  
      index = np.argsort(x)
      sorted_x = x[index]
      sorted_index = np.searchsorted(sorted_x, y)
  
      yindex = np.take(index, sorted_index, mode="clip")
      mask = x[yindex] != y
  
      result = np.ma.array(yindex, mask=mask)
  
      return result
  
  find_indices(a2, a1)
  </code></pre>
  
  <p>This returns this array which seems good.</p>
  
  <pre><code>masked_array(data=[0, --, 1],
               mask=[False,  True, False],
               fill_value=999999)
  </code></pre>
  
  <p>but when I slice using masked_array.data, I get replicated data,</p>
  
  <pre><code>a2[idx.data]
  
  array([['a', '4.67'],
     ['c', '2.24'],
     ['c', '2.24']], dtype='&lt;U4')
  </code></pre>
  
  <p>whereas the output should be:</p>
  
  <pre><code>array([['a', '4.67'],
               --     , 
         ['c', '2.24']], dtype='&lt;U4')
  </code></pre>
  
  <p>How to fix this bug?</p>