給試算表使用者的 Python
Chris Cardillo
Data Scientist
fruit_sales.groupby('store', as_index=False).mean()


totals = fruit_sales.groupby(['store', 'product_name'], as_index=False).sum()

totals = (totals.sort_values('revenue', ascending=False)
.reset_index(drop=True))

top_store_sellers = totals.groupby('store').head(1).reset_index(drop=True)

# 原始資料
fruit_sales
# 彙總-依水果與門市
totals = fruit_sales.groupby(['store', 'product_name'], as_index=False).sum()
# 對彙總排序
totals = (totals.sort_values('revenue', ascending=False)
.reset_index(drop=True))
# 各店第一列
top_store_sellers = totals.groupby('store').head(1).reset_index(drop=True)







給試算表使用者的 Python