读取Excel文件house_ unit price.xlsx, 利用列MSZoning分组,计算unitPrice的均值,并按照unitPrice均值降序排列后以柱状图可视化显示该均值。要求以列MSZoning为x轴,轴刻度分别为C、FV、NA、RH、RL、RM,包括图例、图标题,填充颜色为蓝色,并保存为house_ unit price.png; 要求分辨率不低于300 dpi.
import pandas as pd
import matplotlib.pyplot as plt
tabel1 = pd.read_excel('house_unit price.xlsx')
a=tabel1.groupby('MSZoning')[['unitPrice']].mean()
b=a.sort_values(by='unitPrice',ascending=False)
plt.plot(b.index.tolist(),b.values.tolist(),label='unitPrice')
plt.title('house_unit price')
plt.legend(loc=0)
plt.show()
做出来大概是这样