title: How do I group rows in pandas?
body: <p>This is what I have tried and the result I would like to achieve. I am using jupyter to execute this code:</p>
  
  <pre><code>import pandas as pd
  
  df = pd.DataFrame( {'a':['A','A','B','B','B','C'], 'b':[1,2,5,5,4,6]})
  
  df
  </code></pre>
  
  <p>output:</p>
  
  <pre><code>  a  b
  0 A  1
  1 A  2
  2 B  5
  3 B  5
  4 B  4
  5 C  6
  </code></pre>
  
  <p>Further I tried:</p>
  
  <pre><code>s = df[['a','b']].groupby(df['a']).sum()
  
       b
  a
  A    3
  B    14
  C    6
  </code></pre>
  
  <p>This is similar to what I wanted in terms of grouping the rows but I dont understand why the label b was way up, should it not be in the same line as a?<br>
  Also, when I iterate through <code>s</code> I only get <code>b</code> and when I iterate thorough <code>a['b']</code> I get all the quantities. However, I want all the letters say iterate over <code>s['a']</code> and get <code>A,B,C</code> but this throws an error. Thanks       </p>