title: how to groupby statement in pandas other than crosstab
body: <p>let say there is a dataframe </p>
  
  <p><code>df = pd.DataFrame( {'col1': ['a', 'a', 'a', 'b', 'b'], 'col2': ['x', 'x', 'y', 'y', 'y']} )</code></p>
  
  <p>I want to show this in a table whose index is <code>a</code> and column <code>x</code> is <code>2</code> and <code>y</code> is <code>1</code> just like in the 1st attached picture (<a href="https://imgur.com/MiWmdIz" rel="nofollow noreferrer">https://imgur.com/MiWmdIz</a>).
  I used crosstab but I am getting two separate rows like in the 2nd attached picture.(<a href="https://imgur.com/WiJWT15" rel="nofollow noreferrer">https://imgur.com/WiJWT15</a>)</p>