title: How to find a list of elements in an array using python
body: <p>I have two sets of data which both have values which refer to part of a larger set of data (points in an unstructured mesh).</p>
  
  <p>The two smaller sets of data contain vectors which have the global id which references the point in the larger set of data. Something like:</p>
  
  <p>Large set of data:</p>
  
  <pre><code>0 0 0
  0 0 1
  0 1 0
  1 0 0
  1 1 0
  1 0 1
  0 1 1
  1 1 1 
  </code></pre>
  
  <p>Smaller sets of data:</p>
  
  <p>A</p>
  
  <pre><code>0 1
  3 5
  4 5 
  6 7 
  7 2 
  </code></pre>
  
  <p>B</p>
  
  <pre><code>0 10
  4 12
  7 60
  </code></pre>
  
  <p>The first column in the smaller sets of data is a reference to the line number in the larger set of data. The second column in the smaller set of data are just example data.</p>
  
  <p>It is also worth mentioning that the first column of B is always a subset of the first column of A.</p>
  
  <p>What I need is the row indices of A where the point ids match those in B.</p>
  
  <p>In this case this would be:</p>
  
  <pre><code>ind = [0,2,4]
  </code></pre>
  
  <p>i.e. 
      A[ind,0] = B[:,0]</p>
  
  <p>I have managed to do this previously using a loop, but now the datasets are increasing in size to over 10 million and the loop is far too slow. Can anyone suggest any faster methods?</p>