title: Data transformation in numpy
body: <ul>
  <li>Input data are lists of 1-D numpy arrays e.g. <code>x[0] = [ array([1.0,1.0,1.0]), array([2.0,2.0,2.0]), ...]</code></li>
  <li><code>len(x)</code> is on the order of a few thousand (rows) while <code>len(x[n])</code> is a fixed number (columns), but may change from run to run (so I don't want to hard-code a number of columns).</li>
  <li>Function <code>f(x[n][col])</code> transforms each <code>array</code> into a single number</li>
  <li>Desired result is a list of transformed columns</li>
  </ul>
  
  <p>The lists are for plotting, so they could be a numpy data structure.
  Here is some code to set up test data and notional transformation:</p>
  
  <pre><code>import numpy
  
  # create test data set
  def datagen(number):
      return numpy.array([number,number,number])
  
  x=[]
  for rows in range(20):
      dataline = [ datagen(n) for n in range(5)]
      x.append(dataline)
  
  #define transformation of array to single number
  def f(in_array):
      return in_array.sum()
  </code></pre>
  
  <p>Desired result-- get in a numpy, pythonic sort of way:</p>
  
  <pre><code>[ array([0,0,0,...0]), array([3,3,3,....,3]), array([6,6,6,...,6]), ..etc]
  </code></pre>
  
  <p>where in this case each array has 20 elements (one for each row of data) and there are 5 arrays in the list (one for each column).</p>
  
  <p>Here is my current solution:</p>
  
  <pre><code>trans = []
  for dataline in x:
      trans.append([f(a) for a in dataline])
  
  trans = numpy.array(trans)
  answer = [ trans[:,col] for col in range(len(x[0])) ]
  </code></pre>
  
  <p>Not too shabby but my head hurts and I have a feeling this can be done better. ???</p>
  
  <p>In real life f(a) = <code>numpy.sqrt(numpy.vdot(a,a))</code>.</p>