From the given dataset ‘mtcars.csv’, plot a histogram to check the frequency distribution of the variable ‘mpg’ (Miles per gallon) and find the highest frequency of interval. For data science using Python in Anaconda - Jupyter
#import the library Pandas
import pandas as pd
#Put the mtcars.csv dataset on Root Directory
#Read the dataset
data = pd.read_csv('mtcars.csv')
#From the given dataset ‘mtcars.csv’, plot a histogram to check the frequency distribution of
#the variable ‘mpg’ (Miles per gallon).
#Find the highest frequency of interval
import matplotlib.pyplot as plt
#=========================================
# Histogram
#=========================================
plt.hist(data['mpg'],density = False)
plt.title('Histogram of miles per gallon')
plt.xlabel('miles per gallon')
plt.ylabel('Frequency')
plt.show()
Output:-