How to plot values in a bar chart from a specific DataFrame column

Viewed 58

Shown below are few rows in the DataFrame and these are the columns 'Category', 'Content Rating' and 'Reviews'.

enter image description here

Below shown is an extract taken from a particular DataFrame column "Content Rating".

In: pd.value_counts(Data['Content Rating'])  #Considered the total value count from the df column

out:   A       1000
       B        918
       C        360
       D        305
       E          3
       F          1

And this is the extract taken to plot a bar char

In: a = pd.value_counts(Data['Content Rating'])
    a.plot(kind='bar')

Out:

enter image description here

I want to have the values in the bar char.

The resulting bar chart should look like this:

enter image description here

1 Answers

Try this:

for i, v in enumerate([x[0] for x in a.values.tolist()]):
    plt.text(v + 3, i + .25, str(v), color='blue', fontweight='bold')
Related