Skip to content

Commit

Permalink
Updated window functions exercises
Browse files Browse the repository at this point in the history
  • Loading branch information
inesmcm26 committed Jun 28, 2024
1 parent 0bfbbe1 commit 85e181f
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions 03_pyspark_advanced/03_01_window_functions/exercises.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -144,19 +144,22 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"6. Determine the top 3 products with the highest profit margin.\n",
"6. Determine the top 3 products with the highest profit margin, for each supplier country.\n",
"\n",
"Profit margin refers to the ratio between profit and revenue:\n",
"\n",
"$profit\\_margin_{product} = profit_{product} / revenue_{product}$\n",
"\n",
"where\n",
"\n",
"$profit_{product} = revenue_{product} - cost_{product}$\n",
"\n",
"Let's break this question down:\n",
"- To calculate the cost of each product's order, we need to multiply the cost per unit by the quantity ordered\n",
"- Then, we want to get the total revenue and total cost of each product, for each supplier country\n",
"- Next, the profit is calculated as the difference between revenue and cost and the profit margin is calculated as the ratio between profit and revenue\n",
"- Finally, we rank the products by profit margin and select the top 3"
"- To calculate the profit of each product in each supplier country, we need to calculate its total revenue and cost for each supplier country\n",
"- To calculate the total cost of each product, we need to multiply the cost per unit by the quantity ordered in each order\n",
"- Next, the profit is calculated as the difference between total revenue and total cost\n",
"- The profit margin is calculated as the ratio between profit and total revenue\n",
"- Finally, the products are ranked by profit margin and the top 3 are selected"
]
},
{
Expand Down

0 comments on commit 85e181f

Please sign in to comment.