You work in XYZ Corporation as a Data Analyst. Your corporation has told you to visualize the mtcars.csv dataset with various plots. Tasks to be performed:
Dataset Link 1. Plot a histogram for the column ‘wt’.
a. Map the ‘wt’ onto the x-axis.
b. Provide the x-axis label as ‘weight of the cars’.
c. Provide the y-axis label as ‘Count’
d. Set the number of bins as 30.
e. Set the title as ‘Histogram for the weight values
import statsmodels.api as sm
import pandas as pd
import matplotlib.pyplot as plt
mtcars = sm.datasets.get_rdataset('mtcars','datasets', cache=True).data
df=pd.DataFrame(mtcars)
df['wt'].plot(kind='hist',bins=30,title='Histogram for the weight values')
plt.xlabel("Weight of the cars")
plt.ylabel('Count')
Comments
Leave a comment