title: Creating percentage stacked bar chart using groupby
body: <p>I'm looking at home ownership within levels of different loan statuses, and I'd like to display this using a stacked bar chart in percentages.</p>
  
  <p>I've been able to create a frequency stacked bar chart using this code:</p>
  
  <pre><code>df_trunc1=df[['loan_status','home_ownership','id']]
  sub_df1=df_trunc1.groupby(['loan_status','home_ownership'])['id'].count()
  sub_df1.unstack().plot(kind='bar',stacked=True,rot=1,figsize=(8,8),title="Home ownership across Loan Types")
  </code></pre>
  
  <p>which gives me this picture:<a href="https://i.stack.imgur.com/hTgvs.png" rel="nofollow noreferrer">1</a></p>
  
  <p>but I can't figure out how to transform the graph into percentages. So for example, I'd like to get within the default group, which percentage have a mortgage, which own, etc.</p>
  
  <p>Here is my groupby table for context<a href="https://i.stack.imgur.com/Y7APz.png" rel="nofollow noreferrer">2</a>:</p>
  
  <p>Thanks!!</p>