I m trying to show the number of counts in each color bar . is there a way to do that ? here is the code:
import pandas as pd
# sample data
data = {'fields': ['LastName', 'Race', 'Email', 'MidName', 'StreetAddress', 'Phone', 'State',
'FirstName', 'Gender', 'Expiration', 'StreetAddress'],
'Status': ['complete', 'missing', 'missing', 'complete', 'complete', 'missing', 'missing',
'complete', 'complete', 'complete', 'missing'],
'count': [27399, 146, 24225, 26078, 27269, 59, 28, 27399, 27403, 14017, 134]}
df = pd.DataFrame(data)
# pivot the dataframe into the wide form
dfp = df.pivot(index='Status', columns='fields', values='count')
# get the totals along the rows
tot = dfp.sum(axis=1)
# calculate percent
per = dfp.div(tot, axis=0).mul(100).round(2)
# plot
ax = per.plot(kind='bar', stacked=True, figsize=(8, 6), rot=0)
ax.legend(bbox_to_anchor=(1, 0.5), loc='center left', frameon=False)
i m getting the percentages but i also want to be able to show in each box the counts - for example email in the right bar is 24225 and i want that total to be there . how do i do that ?