Closed leopensaa closed 2 years ago
Here is the solution for this issued graph
total_sales_categories_year = products_df[['order_id','purchase_year','price','product_category_name_english']]
top5_cat_year = total_sales_categories_year.groupby(['purchase_year','product_category_name_english'],as_index=False).agg({'price':'sum'}).sort_values(by=['purchase_year','price'], ascending=False)
top5_cat_year = top5_cat_year.groupby('purchase_year').head(5).reset_index(drop=True)
top5_cat_year
fig = px.bar(top5_cat_year,x='purchase_year',y='price',color='product_category_name_english')
fig.show()
Resulting chart
Notice that the amount of purchases of 2016 is not comparable with the others, and also has different top 5 categories: (this can be seeing by zooming the plotly chart
💡 Goal
Show the total of sales made per year during the study period (2016-2018) including their products category.
🤝 Acceptance Criteria
See the Notion reference with pictures as example