Pandas - Plotting a stacked Bar Chart Pandas - Plotting a stacked Bar Chart python python

Pandas - Plotting a stacked Bar Chart


Are you getting errors, or just not sure where to start?

%pylab inlineimport pandas as pdimport matplotlib.pyplot as pltdf2 = df.groupby(['Name', 'Abuse/NFF'])['Name'].count().unstack('Abuse/NFF').fillna(0)df2[['abuse','nff']].plot(kind='bar', stacked=True)

stacked bar plot


That should help

df.groupby(['NFF', 'ABUSE']).size().unstack().plot(kind='bar', stacked=True)


Maybe you can use pandas crosstab function

test5 = pd.crosstab(index=faultdf['Site Name'], columns=faultdf[''Abuse/NFF''])test5.plot(kind='bar', stacked=True)