I have data like this. I would like to make a stacked bar chart where the x-axis is the ball color and each stack in the bar is the percentage of balls with that color that have that attribute (note each column in the bar chart will not sum to 100). I'm trying something like this
data = {'Ball Color' : ['Red', 'Blue', 'Blue', 'Red', 'Red', 'Red'],
'Heavy?' : [True, True, False, True, False, True],
'Shiny?' : [True, True, False, True, True, False]}
code_samp = pd.DataFrame(data)
code_samp.groupby('Ball Color')[['Heavy?', 'Shiny?']].value_counts().plot.bar()
But value_counts is only supported for series. Any ideas? Thanks in advance
code_samp.groupby('Ball Color').sum().plot.bar()
? – Scott Boston