title: Pandas - convert columns to grouped array coordinates
body: <p>I have a DataFrame of (x, y) coordinates that I would like to transform into array's to perform pairwise distance calculations on.</p>
  
  <pre><code>df = pd.DataFrame({'type':      ['a', 'a', 'a', 'b', 'b', 'c', 'c', 'c'],
  ...                      'x': [1, 3, 5, 1, 3, 1, 3, 5],
  ...                      'y':   [2, 4, 6, 2, 4, 2, 4, 6]})
  </code></pre>
  
  <p>Desired output - A new DataFrame of grouped/aggregated coordinates in an array so that I can apply a fuction to each array:</p>
  
  <pre><code>grp =       coordinates
      a    array([[1, 2],
                 [3, 4],
                 [5, 6]])
  
      b    array([[1, 2],
                 [3, 4]])
  
      c    array([[1, 2],
                 [3, 4],
                 [5, 6]])
  </code></pre>
  
  <p>Distance calculation I wish to apply...</p>
  
  <pre><code>grp['distances'] = grp.apply(lambda x: scipy.spatial.distance.pdist(x['coordinates'], 'euclidean'), axis = 1)
  </code></pre>
  
  <p>I can't seem to get the groupby function to do this. Any ideas?</p>