title: Pandas: groupby and then retrieving IQR
body: <p>I am quite new to Pandas and I am trying to do the following thing:</p>
  <p>I have two dataframes <code>comms</code> and <code>arts</code> that look like this (except for the fact they are longer ad with other columns)</p>
  <p>comms:</p>
  <pre><code>ID    commScore           
  10       5                
  10       3                  
  10      -1                 
  11       0                
  11       2              
  12       9      
  13      -2     
  13      -1     
  13       1      
  13       4
  </code></pre>
  <p>arts:</p>
  <pre><code>ID    commNumber
  10        3 
  11        2    
  12        1
  13        4      
  </code></pre>
  <p>I need to group <code>comms</code> by their ID, and then save in <code>arts</code> (obviously in the correct ID line) the interquartile range (<em>IQR</em>) of the commScore distribution for each ID.</p>
  <p>I've already tried using <code>groupby</code>, <code>agg</code> and <code>map </code>, but since my notions of <code>pandas</code> are quite limited, I just couldn't do what I was looking for.</p>
  <p>Does anyone have a solution?</p>
  <p>Thanks</p>
  <p>Andrea</p>