[英]How to make seaborn barplot with sum of values in y-axis
我想制作一個seaborn barplot,將年份列作為x軸,並將每年的AveragePrice的總和作為y軸。 到目前為止,我想到了 groupby year 但它似乎沒有用。 我該怎么辦?
plt.figure()
ax = sns.barplot(avo_sales.year, avo_sales.groupby(['year'])['AveragePrice'].sum())
由於您按年份分組,因此您還需要確保 y 軸只有唯一的年份:
ax = sns.barplot(avo_sales.year.unique(),
avo_sales.groupby(['year'])['AveragePrice'].sum())
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.