title: building a pairwise matrix in scipy/numpy in Python from dictionaries
body: <p>I have a dictionary whose keys are strings and values are numpy arrays, e.g.:</p>
  
  <pre><code>data = {'a': array([1,2,3]), 'b': array([4,5,6]), 'c': array([7,8,9])}
  </code></pre>
  
  <p>I want to compute a statistic between all pairs of values in 'data' and build an n by x matrix that stores the result.  Assume that I know the order of the keys, i.e. I have a list of "labels":</p>
  
  <pre><code>labels = ['a', 'b', 'c']
  </code></pre>
  
  <p>What's the most efficient way to compute this matrix?</p>
  
  <p>I can compute the statistic for all pairs like this:</p>
  
  <pre><code>result = []
  for elt1, elt2 in itertools.product(labels, labels):
    result.append(compute_statistic(data[elt1], data[elt2]))
  </code></pre>
  
  <p>But I want result to be a n by n matrix, corresponding to "labels" by "labels".  How can I record the results as this matrix?
  thanks.</p>