title: Numpy Arrays comparison and indexing
body: <p>I have 2 arrays of unequal size:</p>
  
  <pre><code>&gt;&gt;&gt; np.size(array1)
  4004001
  &gt;&gt;&gt; np.size(array2)
  1000 
  </code></pre>
  
  <p>Now, each element in array2 needs to be compared to all the elements in array1, to find the element which has the nearest value to that of this element in array2. 
  Upon finding this value, I need to store it in a different array of size 1000 - one of a size corresponding to array2. </p>
  
  <p>The tedious and crude way of doing it could be using a for loop and taking each element from Array 2, subtracting its absolute value from array 1 elements and then taking the minimum value- this is going to make my code really slow. </p>
  
  <p>I'd like to use numpy vectorized operations to do this but i've kind of hit a wall.</p>