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

0 stars 6 forks source link

feat: Graph 1. Main numbers #61

Closed leopensaa closed 2 years ago

leopensaa commented 2 years ago

💡 Goal

Show the % of growth between the study periods (2016-2018), the total earnings from sales made by E-commerce in Brazil, and the Top 3 States with the highest sales.

🤝 Acceptance Criteria

See the Notion reference with pictures as example

felipesaldata commented 2 years ago

here i'm sharing the code slices to complete the pending acceptance criteria:

growth % is at our current dashboard: a2.metric("2017-2018 Growth",format(products_Maximun["%Growth"].iloc[0],'.2f')+'%')

revenue per year in numbers: is taken from the df that makes the chart (dataframe: ord_by_M)

The 3 states with the highest sales: states_sales_count = products_df.groupby(['customer_state'], as_index=False).count() states_sales_count.rename(columns={'price':'Number_sales'}, inplace=True) states_sales_count = states_sales_count[['customer_state','Number_sales']] states_sales_amount = products_df.groupby(['customer_state'], as_index=False).sum() states_sales_amount.rename(columns={'price':'Total_revenue'}, inplace=True) states_sales_amount = states_sales_amount[['customer_state','Total_revenue']] top3_states_sales = states_sales_count.merge(states_sales_amount, on='customer_state').sort_values(by='Total_revenue', ascending=False).head(3) top3_states_sales