pandas histogram code example

Example 1: pandas plot histogram

ax = df.plot.hist(bins=12, alpha=0.5)

Example 2: pandas groupby histogram

# pandas hostogram on group by
df['N'].hist(by=df['Letter'])

Example 3: show distribution pandas coloumns

df['age'] == ['14','16','23','54']
df['age'].hist()

Example 4: histogram python

>>> np.histogram([1, 2, 1], bins=[0, 1, 2, 3])
(array([0, 2, 1]), array([0, 1, 2, 3]))
>>> np.histogram(np.arange(4), bins=np.arange(5), density=True)
(array([0.25, 0.25, 0.25, 0.25]), array([0, 1, 2, 3, 4]))
>>> np.histogram([[1, 2, 1], [1, 0, 1]], bins=[0,1,2,3])
(array([1, 4, 1]), array([0, 1, 2, 3]))