title: Scipy distance: Computation between each index-matching observations of two 2D arrays
body: <p>I am trying to compute distance metrics between two 2D arrays, let's say A and B (n 'rows' x 6 'cols' each) using the <code>scipy.spatial.distance</code> functions. I would like to compute these distances between each pair of observations <strong>that correspond to the same index</strong> (e.g. between A[i,:] and B[i,:]) efficiently (i.e. without looping over the array index).</p>
  
  <p>I know that <code>scipy.spatial.distance.cdist</code> achieves this quickly, but between <strong>all pairs</strong> of observations, including those that not match in index. Therefore, I am looking for an quivalent but only for index-matching observations.</p>
  
  <p>Here is an simple example for computing the euclidean distance:</p>
  
  <pre><code>import numpy as np
  from scipy.spatial import distance
  
  a = np.array([[1, 5, 6, 7, 8, 7, 9], [5, 7, 8, 6, 4, 1, 2]])
  b = np.array([[9, 8, 9, 5, 7, 1, 2], [1, 5, 5, 7, 2, 1, 1]])
  
  print(distance.cdist(a, b, 'euclidean')) # Compute the euclidean distance between each pair
  
  for i in range(0, len(a), 1):
      print(distance.euclidean(a[i,:], b[i,:])) # Do the job but too long
  </code></pre>
  
  <p>Thank you for your help!</p>