title: Python/Pandas for solving grouped mean, median, mode and standard deviation
body: <p>I have the following data:</p>
  
  <pre><code>[4.1, 4.1, 4.1, 4.2, 4.3, 4.3, 4.4, 4.5, 4.6, 4.6, 4.8, 4.9, 5.1, 5.1, 5.2, 5.2, 5.3, 5.3, 5.3, 5.4, 5.4, 5.5, 5.6, 5.6, 5.6, 5.7, 5.8, 5.9, 6.2, 6.2, 6.2, 6.3, 6.4, 6.4, 6.5, 6.6, 6.7, 6.7, 6.8, 6.8]
  </code></pre>
  
  <p>I need to build its count/frequency table like this based on the data above:</p>
  
  <pre><code>4.1 - 4.5: 8
  4.6 - 5.0: 4
  5.1 - 5.5: 10
  5.6 - 6.0: 6
  6.1 - 6.5: 7
  6.6 - 7.0: 5
  </code></pre>
  
  <p>The closest I can get is the following result:</p>
  
  <pre><code>            counts  freqs
   categories               
  [4.1, 4.6)       8  0.200
  [4.6, 5.1)       4  0.100
  [5.1, 5.6)      10  0.250
  [5.6, 6.1)       6  0.150
  [6.1, 6.6)       7  0.175
  [6.6, 7.1)       5  0.125
  </code></pre>
  
  <p>Through this code:</p>
  
  <pre><code>sr = [4.1, 4.1, 4.1, 4.2, 4.3, 4.3, 4.4, 4.5, 4.6, 4.6, 4.8, 4.9, 5.1, 5.1, 5.2, 5.2, 5.3, 5.3, 5.3, 5.4, 5.4, 5.5, 5.6, 5.6, 5.6, 5.7, 5.8, 5.9, 6.2, 6.2, 6.2, 6.3, 6.4, 6.4, 6.5, 6.6, 6.7, 6.7, 6.8, 6.8]
  ncut = pd.cut(sr, [4.1, 4.6, 5.1, 5.6, 6.1, 6.6, 7.1],right=False)
  
  srpd = pd.DataFrame(ncut.describe())
  </code></pre>
  
  <p>I need to create a new column, which is the median of the "categories" value (e.g. for "[4.1, 4.6)", this contains the count / frequency of data from 4.1 to 4.5 (not including 4.6)), So I need to get (4.1 + 4.5) / 2, which is equal to 4.3. </p>
  
  <p>Here are my questions:</p>
  
  <p>1) How do I access the values under the "categories" index to use it for computation like above?</p>
  
  <p>2) Is there a way to reflect the range in this way: 4.1 - 4.5, 4.6 to 5.0, etc..?</p>
  
  <p>3) Is there an easier way to compute for mean, median, mode, etc for grouped data like these? or do I have to create my own functions for these in Python?</p>
  
  <p>Thanks</p>