title: iterating over lists finding standard deviation of each point
body: <p>I have this section of code that is supposed to find the standard deviation of each number in A, where A is a list of lists consisting of 7 values.</p>
  
  <pre><code>def sigma(A):
      diff = 0
      positives = [b for b in A if b &gt;= 0]
      if positives:
          mean = sum(positives) / len(positives)
          for i in positives:  
              diff = ((sum([abs(i - mean)**2 for i in positives]))/(len(positives)))**(0.5)
              return diff
      else:
          return 0
  
      G = map(sigma, zip(*A))
      print G
  </code></pre>
  
  <p>this correctly gives me the standard deviation for the first list of 7 numbers but shouldn't <code>map(sigma, zip(*A))</code> make it iterate over all the lists? I have also tried <code>[sigma(A) for col in xrange(len(rows[0]))]</code> but that did not work either. Ideally the standard deviations would also be saved as a list of lists of seven. Any help is appreciated.</p>
  
  <p>UPDATE:
  this is the code that I have now; </p>
  
  <pre><code>def sigma(A):
      diff = 0
      positives = [b for b in A if b &gt;= 0]
      if positives:
          mean = sum(positives) / len(positives)
          diff += ((sum([abs(i - mean)**2 for i in positives]))/(len(positives)))**(0.5)
          for i in positives:
              if (abs(i - mean)) &gt; (diff*3):
                  return -9999.00
              else:
                  return i
  
      else:
          return -9999.00
  
  G = map(sigma, zip(*A))
  print G
  </code></pre>
  
  <p>it does all the things I want it to do however when I run it this way it only outputs for the first row. If the 'return' statements are replace with 'print' and <code>print G</code> is removed the outputs I want for all the rows are printed. How can I store all these values in a list? I'm assuming it's this line <code>G = map(sigma, zip(*A))</code> that's the problem. I tried changing it to <code>G = map(sigma, A)</code> however this only gives me the numbers for the first column.
  Does anyone have any ideas?</p>