Answer to Question #322716 in Python for Shilpa

Question #322716

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




1
Expert's answer
2022-04-03T03:44:57-0400
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')




Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS