Learn Before
Code
Matplotlib Histogram
Using this dataframe,
df = pd.DataFrame({ 'name':['john','mary','peter','jeff','bill','lisa','jose'], 'age':[23,78,22,19,45,33,20], 'gender':['M','F','M','M','M','F','M'], 'state':['california','dc','california','dc','california','texas','texas'], 'num_children':[2,0,0,3,2,1,4], 'num_pets':[5,1,0,5,2,2,3] })
To create a histogram of the age column,
#bins sets range for bins #rwidth is relative width of bars df[['age']].plot(kind='hist',bins=[0,20,40,60,80,100],rwidth=0.8) plt.show()

0
1
Updated 2021-07-29
Tags
Python Programming Language
Data Science