I want to plot this data frame but I get an error. this is my df:
6month final-formula Question Text
166047.0 1 0.007421 bathing
166049.0 1 0.006441 dressing
166214.0 1 0.001960 feeding
166216.0 2 0.011621 bathing
166218.0 2 0.003500 dressing
166220.0 2 0.019672 feeding
166224.0 3 0.012882 bathing
166226.0 3 0.013162 dressing
166229.0 3 0.008821 feeding
160243.0 4 0.023424 bathing
156876.0 4 0.000000 dressing
172110.0 4 0.032024 feeding
how can I plot a stacked bar based on the Question text
?
I tried some codes but raises error.
dffinal.groupby(['6month','Question Text']).unstack('Question Text').plot(kind='bar',stacked=True,x='6month', y='final-formula')
import matplotlib.pyplot as plt
plt.show()
Actually I want the 6month
column be in the x-axis
, final-formula
in the y-axis
and Question text
being stacked.
so as here I have three kind of Question text
, three stacked bar should be there. and as I have 4 month
, 4 bars totally.
Something like this but I applied this and did not work. Am I missing something?
this picture is without stacking them. its like all question text
has been summed up. I want for each Question Text
there be stacked.