title: How is pandas groupby method actually working?
body: <p>So I was trying to understand pandas.dataFrame.groupby() function and I came across this example on the documentation:</p>
  
  <pre><code>    In [1]: df = pd.DataFrame({'A' : ['foo', 'bar', 'foo', 'bar',
     ...:                           'foo', 'bar', 'foo', 'foo'],
     ...:                    'B' : ['one', 'one', 'two', 'three',
     ...:                           'two', 'two', 'one', 'three'],
     ...:                    'C' : np.random.randn(8),
     ...:                    'D' : np.random.randn(8)})
     ...: 
  
  In [2]: df
  Out[2]: 
       A      B         C         D
  0  foo    one  0.469112 -0.861849
  1  bar    one -0.282863 -2.104569
  2  foo    two -1.509059 -0.494929
  3  bar  three -1.135632  1.071804
  4  foo    two  1.212112  0.721555
  5  bar    two -0.173215 -0.706771
  6  foo    one  0.119209 -1.039575
  7  foo  three -1.044236  0.271860
  </code></pre>
  
  <p>Not to further explore I did this:</p>
  
  <pre><code>print(df.groupby('B').head())
  </code></pre>
  
  <p>it outputs the same dataFrame but when I do this:</p>
  
  <pre><code>print(df.groupby('B'))
  </code></pre>
  
  <p>it gives me this:</p>
  
  <pre><code>&lt;pandas.core.groupby.DataFrameGroupBy object at 0x7f65a585b390&gt;
  </code></pre>
  
  <p>What does this mean? In a normal dataFrame printing <code>.head()</code> simply outputs the first 5 rows what's happening here?</p>
  
  <p>And also why does printing <code>.head()</code> gives the same output as the dataframe? Shouldn't it be grouped by the elements of the column <code>'B'</code>?</p>