title: Convert a GroupBy object (groupby().size) into a dictionary
body: <p>Here is my try at something simpler.</p>
  
  <pre><code>demo = pd.DataFrame(data=np.array([["APPLE", "APPLE", "APPLE", "MANGO", "MANGO"],
                               ["DOWN", "DOWN", "DOWN", "UP", "DOWN"]]))
  
  demo = demo.T
  demo.columns = ['FRUIT', 'DIRECTION']
  </code></pre>
  
  <p>Here is what the above data frame looks like</p>
  
  <pre><code>    FRUIT   DIRECTION
  0   APPLE   DOWN
  1   APPLE   DOWN
  2   APPLE   DOWN
  3   MANGO   UP
  4   MANGO   DOWN
  </code></pre>
  
  <p>and now</p>
  
  <pre><code>labels = demo["DIRECTION"]
  l, v = np.unique(labels, return_counts=True)
  d = dict(zip(l, v))
  print(d)
  </code></pre>
  
  <p>This gives me the unique counts of the 'DIRECTIONS' column. </p>
  
  <pre><code>{'DOWN': 3, 'UP': 2}
  </code></pre>
  
  <p>Now, what if I wanted to find the frequency of counts of 'FRUIT' column grouped by 'DIRECTION' column.</p>
  
  <p>I did do this.</p>
  
  <pre><code>print(demo.groupby(['FRUIT', 'DIRECTION']).size())
  </code></pre>
  
  <p>This gave me, </p>
  
  <pre><code>FRUIT  DIRECTION
  APPLE  DOWN         3
  MANGO  DOWN         1
         UP           1
  </code></pre>
  
  <p>I have issues with the above output.</p>
  
  <p>I wanted to be able to do the following:</p>
  
  <p>a) APPLE has nothing in the UP direction, so I wanted that to show as 0.
  like the table given below.</p>
  
  <pre><code>FRUIT  DIRECTION
  APPLE  DOWN         3
         UP           0
  MANGO  DOWN         1
         UP           1
  </code></pre>
  
  <p>b) I wanted to be able to create it to a dictionary like so</p>
  
  <pre><code>{'APPLE': {DOWN: 3, UP: 0}, 'MANGO': {DOWN: 1, UP: 1}}
  </code></pre>
  
  <p>Any other way to reproduce the above dictionary is also fine. I'm using Python 3.</p>