title: First n elements of row in numpy array
body: <p>I'm trying to implement a k-nearest neighbour classifier in Python, and so I want to calculate the Euclidean distance. I have a dataset that I have converted into a big numpy array</p>
  
  <pre><code>[[  0.   0.   4. ...,   1.   0.   1.]
   [  0.   0.   5. ...,   0.   0.   1.]
   [  0.   0.  14. ...,  16.   9.   1.]
   ..., 
   [  0.   0.   3. ...,   2.   0.   3.]
   [  0.   1.   7. ...,   0.   0.   3.]
   [  0.   2.  10. ...,   0.   0.   3.]]
  </code></pre>
  
  <p>where the last element of each row indicates the class. So when calculating the Euclidean distance, I obviously don't want to include the last element. I thought I could do the following</p>
  
  <pre><code>for row in dataset:
      distance = euclidean_distance(vector, row[:dataset.shape[1] - 1])
  </code></pre>
  
  <p>but that still includes the last element</p>
  
  <pre><code>print row
  &gt;&gt;&gt; [[  0.   0.   4. ...,   1.   0.   1.]]
  print row[:dataset.shape[1] - 1]
  &gt;&gt;&gt; [[  0.   0.   4. ...,   1.   0.   1.]]
  </code></pre>
  
  <p>as you can see both are the same.</p>