I'm stuck on how to add the data values to bar plot in pandas. I've been searching how to do this for several hours now and am finally turning to stack overflow.
I wrote:
# import data and packages
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import rc
%matplotlib inline
df = pd.read_csv('2018_ms_data_impact_only_10_2_18.csv', low_memory=False)
df.head()
ExternalReference interest_el interest_pl interest_ad interest_ol commitment_elected commitment_policy commitment_advocacy commitment_organizing timeline_elected ... Policy Organizing Engagement Parent Veteran first_gen_american first_gen_college ri_region LGBTQ Gender
0 0034000001RHCU0AAP 1.0 1.0 1.0 1.0 0.0 0.0 0.0 0.0 0.0 ... 0.0 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 Woman
1 00340000015yDbOAAU 1.0 1.0 1.0 2.0 0.0 0.0 0.0 2.0 0.0 ... 0.0 1.0 2.0 0.0 0.0 0.0 0.0 1.0 0.0 Man
2 0034000000y3QjMAAU 1.0 2.0 2.0 2.0 0.0 2.0 3.0 4.0 0.0 ... 5.0 2.0 3.0 0.0 0.0 0.0 0.0 1.0 0.0 Man
3 0034000001qcNXRAA2 1.0 1.0 1.0 3.0 0.0 0.0 0.0 3.0 0.0 ... 0.0 1.0 6.0 0.0 0.0 0.0 0.0 1.0 0.0 Woman
4 0034000001DVPedAAH 1.0 1.0 1.0 1.0 0.0 0.0 0.0 0.0 0.0 ... 0.0 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 Woman
# plot question
df['impact_action_yn']
ax = df['impact_action_yn'].value_counts().plot(kind= 'bar', figsize = (6,6))
# add some text for labels, title and axes ticks
ax.set_ylabel('Count')
ax.set_title('Taken an Impact Action in the Last 12 Months')
ax.set_xticklabels(('No', 'Yes'));
I'd like to be able to show the values of the counts of y and n, floating just above the tops of teh bars, centered. How do I plot the values of the df?