title: TypeError: unsupported operand type(s) for /: 'list' and 'long'
body: <p>I am clustering the data into two clusters then I am going to calculate the mean vector but I got the following error.  However, when I change [3,7] to [3,1], the problem will be solved!!! anyone can help me? Thank you in advance</p>
  
  <pre><code>Traceback (most recent call last):
    File "ao.py", line 36, in &lt;module&gt;
      (r,d,u)=update(clusters)
    File "ao.py", line 30, in update
      c=np.mean(d, axis=0)
    File "E:\Python27\lib\site-packages\numpy\core\fromnumeric.py", line 2716, in
  mean
      out=out, keepdims=keepdims)
    File "E:\Python27\lib\site-packages\numpy\core\_methods.py", line 69, in _mean
  
      ret = ret / rcount
  TypeError: unsupported operand type(s) for /: 'list' and 'long'
  </code></pre>
  
  <hr>
  
  <pre><code>import numpy as np
  clusters = {}
  X = np.array([[1,1],[1.5,2],[3,4],[5,7],[3.5,5],[3,7],[3.5,4.5],[5,8],[5,1],[2,3]])
  centroid = ([[2.6,2],[4,6.3]])
  
  def a(X):  
      for x in X:     
          z= min([(i[0], np.linalg.norm(x-centroid[i[0]]))  for i in enumerate(centroid)], key=lambda t:t[1])
  
          try:
              clusters[z].append(x)
          except KeyError:
              clusters[z]=[x]
      return clusters
  
  def update (clusters):
      d=[]
      r=[]
      c=[]
      keys = sorted(clusters.keys())
      for k in keys:
          if k[0]==0:
              r.append(clusters[(k[0],k[1])])       
          else:
              d.append(clusters[(k[0],k[1])])
  
      c=np.mean(d, axis=0)
      u=np.mean(r,axis=0) 
      return(u,c)
  
  
  clusters=a(X)
  (u,c)=update(clusters)
  
  print "c:",c
  print "u:",u
  </code></pre>