title: Multidimensional Euclidean Distance in Python
body: <p>I want to calculate the Euclidean distance in multiple dimensions (24 dimensions) between 2 arrays. I'm using numpy-Scipy. </p>
  
  <p>Here is my code:</p>
  
  <pre><code>import numpy,scipy;
  
  A=numpy.array([116.629, 7192.6, 4535.66, 279714, 176404, 443608, 295522, 1.18399e+07, 7.74233e+06, 2.85839e+08, 2.30168e+08, 5.6919e+08, 168989, 7.48866e+06, 1.45261e+06, 7.49496e+07, 2.13295e+07, 3.74361e+08, 54.5, 3349.39, 262.614, 16175.8, 3693.79, 205865]);
  
  B=numpy.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 151246, 6795630, 4566625, 2.0355328e+08, 1.4250515e+08, 3.2699482e+08, 95635, 4470961, 589043, 29729866, 6124073, 222.3]);
  </code></pre>
  
  <p>However, I used <code>scipy.spatial.distance.cdist(A[numpy.newaxis,:],B,'euclidean')</code> to calcuate the eucleidan distance.</p>
  
  <p><strong>But it gave me an error</strong></p>
  
  <pre><code>raise ValueError('XB must be a 2-dimensional array.');
  </code></pre>
  
  <p>I don't seem to understand it. </p>
  
  <p>I looked up <code>scipy.spatial.distance.pdist</code> but don't understand how to use it? </p>
  
  <p><strong>Is there any other better way to do it?</strong></p>