title: How to get a Series of json/dictionaries from pandas Dataframe groupby object
body: <p>I have a Dataframe with more than 2 columns (Col1, Col2, etc...), and I want to generate a Series where the index is Col1 and the values of the Series are dictionaries where the key is Col2 and the value (of the dict) is the occurrencies of the tuple (Col1, Col2).</p>
  
  <p>Let's say the dataframe is something like this:</p>
  
  <pre><code>    Col1 Col2 Col3 ...
   0    A    b   ... 
   1    B    e   ... 
   2    A    a   ... 
   3    C    a   ... 
   4    A    b   ... 
   5    B    c   ... 
   6    A    e   ... 
   7    B    c   ... 
  </code></pre>
  
  <p>The output I want is:</p>
  
  <pre><code>A {'a':1,'b':2,'e':1}
  B {'c':2,'e':1}
  C {'a':1}
  </code></pre>
  
  <p>I managed to it with this loop:</p>
  
  <pre><code>for t in my_df['Col1'].unique(): 
    my_series.loc[t] = my_df[my_df['Col1'] == t].groupby('Col2').size().to_json()
  </code></pre>
  
  <p>but I was wondering if there is a way to do it more efficiently with pandas methods, without iterating.</p>
  
  <p>I was also trying groupby with two indexes:</p>
  
  <pre><code>   my_df.groupby(['Col1','Col2']).size() 
     &gt;
     Col1  Col2
      A     a     1
            b     2
            e     1
      B     c     2
            e     1
      C     a     1
  </code></pre>
  
  <p>but can't find the next step to convert the result to the Series of dict as shown above</p>