I have a pandas dataframe like this:
    Year   Winner
4   1954  Germany
9   1974  Germany
13  1990  Germany
19  2014  Germany
5   1958   Brazil
6   1962   Brazil
8   1970   Brazil
14  1994   Brazil
16  2002   Brazil
How to plot the frequency count of column Winner, so that y axis has frequency and x-axis has name of country?
I tried:
import numpy as np
import pandas as pd
df.groupby('Winner').size().plot.hist()
df1['Winner'].value_counts().plot.hist()
                In pandas you can get the count of the frequency of a value that occurs in a DataFrame column by using Series. value_counts() method, alternatively, If you have a SQL background you can also get using groupby() and count() method.
Note: You also can use this formula =COUNTIF(A1:A10,"AAA-1") to count the frequency of a specific value. A1:A10 is the data range, and AAA-1 is the value you want to count, you can change them as you need, and with this formula, you just need to press Enter key to get the result.
To create a frequency column for categorical variable in an R data frame, we can use the transform function by defining the length of categorical variable using ave function. The output will have the duplicated frequencies as one value in the categorical column is likely to be repeated.
You are close, need Series.plot.bar because value_counts already count frequency:
df1['Winner'].value_counts().plot.bar()

Also working:
df1.groupby('Winner').size().plot.bar()
Difference between solutions is output of value_counts will be in descending order so that the first element is the most frequently-occurring element. 
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With