4.9. Histogram#

  • Great way to learn about numerical data

  • Used to visualize distribution of numeric variable

import pandas as pd
import matplotlib.pyplot as plt
data = {'Month':['Jan','Feb','March','April'],
        'Sales': [99, 98, 95, 90],
        'Profit': [10,20,30,40]
       }
df=pd.DataFrame(data,columns=['Sales','Profit'],index=data['Month'])
df
Sales Profit
Jan 99 10
Feb 98 20
March 95 30
April 90 40
fig,ax=plt.subplots()
ax.hist(df['Sales']) ;
../_images/953ff1a1545c5112aadcf59e679aecc74127a643f54242492cf00ebca84872f9.png