title: Python Pandas GroupBy % calculation
body: <p>I've a dataframe with 2 columns. I'm trying to calculate the % of TypeB on number of records in ID as follows:  </p>
  
  <p>Formula: (Count of TypeB) / (No of records in Group) * 100</p>
  
  <pre><code>Result :
  001 = (2/3) * 100 =&gt; 66.66
  002 = (0/2) * 100 =&gt; 0
  003 = (1/1) * 100 =&gt; 100
  </code></pre>
  
  <p>Dataframe</p>
  
  <pre><code>ID   Type
  001  TypeA
  001  TypeB
  001  TypeB
  002  TypeA
  002  TypeA
  003  TypeB
  </code></pre>
  
  <p>So, far I've been able to groupBy</p>
  
  <pre><code>byID = df.groupby('ID')
  </code></pre>
  
  <p>I was reading panda's crosstab, but can't seem to figure out how to approach the solution</p>