title: Stacked bar plot by grouped data with pandas
body: <p>Let's assume I have <code>pandas</code> dataframe which has many features and I am interested in two. I'll call them <code>feature1</code> and <code>feature2</code>.</p>
  
  <p><code>feature1</code> can have three possible values.
  <code>feature2</code> can have two possible values.</p>
  
  <p>I need bar plot grouped by <code>feature1</code> and stacked by count of rows with each value of <code>feature2</code>. (So that there will be three stacks each with two bars).</p>
  
  <p>How to achieve this?</p>
  
  <p>At the moment I have</p>
  
  <pre><code>import pandas as pd
  df = pd.read_csv('data.csv')
  df['feature1'][df['feature2'] == 0].value_counts().plot(kind='bar',label='0')
  df['feature1'][df['feature2'] == 1].value_counts().plot(kind='bar',label='1')
  </code></pre>
  
  <p>but that is not what I actually want because it doesn't stack them.</p>