matplotlib两个指标分组一次一行代码画图,不需要遍历

两个指标分组一次画图,不需要遍历

# 5个州的药品报告
nf.groupby(['YYYY','State']).DrugReports.sum().unstack().plot()
plt.ylabel('num of DrugReport')
plt.xlabel('time/year')
plt.title('DrugReports from 5 states') # 5个州的药品报告

在这里插入图片描述
其中nf.groupby(['YYYY','State']).DrugReports.sum().unstack()
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/Caiqiudan/article/details/112726706