title: Iterate over a matrix, sum over some rows and add the result to another array
body: <p>Hi there I have the following matrix</p>
  
  <pre><code> [[ 47  43  51  81  54  81  52  54  31  46]
    [ 35  21  30  16  37  11  35  30  39  37]
    [  8  17  11   2   5   4  11   9  17  10]
    [  5   9   4   0   1   1   0   3   9   3]
    [  2   7   2   0   0   0   0   1   2   1]
    [215 149 299 199 159 325 179 249 249 199]
    [ 27  49  24   4  21   8  35  15  45  25]
    [100 100 100 100 100 100 100 100 100 100]]
  </code></pre>
  
  <p>I need to iterate over the matrix summing all elements in rows 0,1,2,3,4 only
  example: I need </p>
  
  <pre><code>  row_0_sum = 47+43+51+81....46
  </code></pre>
  
  <p>Furthermore I need to store each rows sum in an array like this</p>
  
  <pre><code> [row0_sum, row1_sum, row2_sum, row3_sum, row4_sum]
  </code></pre>
  
  <p>So far I have tried this code but its not doing the job:</p>
  
  <pre><code>  mu = np.zeros(shape=(1,6))
  
    #get an average 
    def standardize_ratings(matrix):
   sum = 0
   for i, eli in enumerate(matrix):
       for j, elj in enumerate(eli):
          if(i&lt;5):
           sum = sum + matrix[i][j]
           if(j==elj.len -1):
             mu[i] = sum
             sum = 0
             print "mu[i]="
             print mu[i]
  </code></pre>
  
  <p>This just gives me an <code>Error</code>:  <code>numpy.int32 object has no attribute 'len'</code></p>
  
  <p>So can someone help me. What's the best way to do this and which type of array in Python should I use to store this. Im new to Python but have done programming....</p>
  
  <p>Thannks</p>