title: GroupBy and Cut in Pandas
body: <p>I am trying to group a set of things and perform cuts within the groups dynamically based on the min, max and average of both (min and max) value. </p>
  
  <p>My dataset looks something like this:</p>
  
  <pre><code>Country     Value
  Uganda       210
  Kenya        423
  Kenya        315 
  Tanzania     780 
  Uganda       124
  Uganda       213
  Tanzania     978 
  Kenya        524 
  </code></pre>
  
  <p>What I expect is in which range does each value fall, above or below mid-value:</p>
  
  <pre><code>Country      Value        Range
  Uganda        210        (168.5, 213)
  Uganda        124        (124, 168.5)
  Uganda        213        (168.5, 213)
  Kenya         423        (419.5, 524)
  Kenya         315        (315, 419.5)
  Kenya         524        (419.5, 524)
  Tanzania      780        (780, 879)
  Tanzania      978        (879, 980) 
  </code></pre>
  
  <p>I am able to achieve this if I am doing it with a loop iterating over each group. I am also able to achieve the cuts based on the min and max value over the entire dataset but not individual groups. However, I was wondering if it can be done in a line or two using pandas and not use loops. </p>