title: Calculate pairwise similarity/distance between rows with conditional values in pandas
body: <p>I'm trying to compute distance between between values in rows that share a category. For user_id 1 parameter 1, the distance between 1 and 7 Par 2 distance between 10, 20.</p>
  
  <pre><code>    df1 = pd.DataFrame({"user_id":[1,2,1,2], "Par1":[1, 3, 7,9], "Par2":[10, 15, 20, 22]})
  
         Par1  Par2  user_id
      0     1    10        1
      1     3    15        2
      2     7    20        1
      3     9    22        2
  </code></pre>
  
  <p>I am able to sum up the values:</p>
  
  <pre><code>   df1.groupby([ "user_id"], as_index=False).sum()
  </code></pre>
  
  <p>and my question is, is there a relatively easy way to compute pairwise distances in lieu of the sum()? </p>
  
  <p>desired output</p>
  
  <pre><code>            Par1                  Par2          user_id
      0     similarity[1,7]    similarity[10,20]       1
      1     similarity[3,9]    similarity[15,22]      2
  </code></pre>