C10-Brazilian-e-commerce-modeling-team / brazilian-e-commerce

0 stars 6 forks source link

feat: Graph 2. Total of sales and categories #62

Closed leopensaa closed 2 years ago

leopensaa commented 2 years ago

💡 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

felipesaldata commented 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 Image

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 Image