'How to plot frequency count of pandas column?
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()
Solution 1:[1]
In addition to @jezrael's answer, you can also do:
df1['Winner'].value_counts().plot(kind='bar')
Other one from @jezrael could be:
df1.groupby('Winner').size().plot(kind='bar')
Solution 2:[2]
Just want to say this works with the latest version of plotly. Just need to add ,text_auto=True.
Example:
px.histogram(df, x="User Country",text_auto=True)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | grantog |
