title: Match two numpy arrays to find the same elements
body: <p>I have a task kind of like SQL search. I have a "table" which contains the following 1D arrays (about 1 million elements) identified by <code>ID1</code>:</p>
  
  <pre><code>ID1, z, e, PA, n
  </code></pre>
  
  <p>Another "table" which contains the following 1D arrays (about 1.5 million elements) identified by <code>ID2</code>:</p>
  
  <pre><code>ID2, RA, DEC
  </code></pre>
  
  <p>I want to match <code>ID1</code> and <code>ID2</code> to find the common ones to form another "table" which contains <code>ID, z, e, PA, n, RA, DEC</code>. Most elements in <code>ID1</code> can be found in <code>ID2</code> but not all, otherwise I can use <code>numpy.in1d(ID1,ID2)</code> to accomplish it. Anyone has fast way to accomplish this task? </p>
  
  <p>For example:</p>
  
  <pre><code>ID1, z, e, PA, n
  101, 1.0, 1.2, 1.5, 1.8
  104, 1.5, 1.8, 2.2, 3.1
  105, 1.4, 2.0, 3.3, 2.8
  
  ID2, RA, DEC
  101, 4.5, 10.5
  107, 90.1, 55.5
  102, 30.5, 3.3
  103, 60.1, 40.6
  104, 10.8, 5.6
  </code></pre>
  
  <p>The output should be </p>
  
  <pre><code>ID, z, e, PA, n, RA, DEC
  101, 1.0, 1.2, 1.5, 1.8, 4.5, 10.5
  104, 1.5, 1.8, 2.2, 3.1, 10.8, 5.6
  </code></pre>