Let's assume I have pandas dataframe which has many features and I am interested in two. I'll call them feature1 and feature2.
feature1 can have three possible values.
feature2 can have two possible values.
I need bar plot grouped by feature1 and stacked by count of rows with each value of feature2. (So that there will be three stacks each with two bars).
How to achieve this?
At the moment I have
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')
but that is not what I actually want because it doesn't stack them.
