Write SQL and Python, run instantly in your browser, and track your progress.
You are a Financial Analyst at Costco. The Accounting team needs to calculate the effective unit price for each order item after taxes and discounts are applied. Use apply with axis=1 to compute values from multiple columns in each row.
| Column Name | Type |
|---|---|
| order_item_id | int64 |
| order_id | int64 |
| product_id | int64 |
| quantity | int64 |
You are a Financial Analyst at Costco. The Accounting team needs to calculate the effective unit price for each order item after taxes and discounts are applied. Use apply with axis=1 to compute values from multiple columns in each row.
| Column Name | Type |
|---|---|
| order_item_id | int64 |
| order_id | int64 |
| product_id | int64 |
| quantity | int64 |
| unit_price | float64 |
| unit_price | float64 |
| line_subtotal | float64 |
| line_subtotal | float64 |
| tax_amount | float64 |
| tax_amount | float64 |
| discount_amount | float64 |
| discount_amount | float64 |
| fulfillment_status | object |
| fulfillment_status | object |
| order_item_id | order_id | product_id | quantity | unit_price | line_subtotal | tax_amount | discount_amount | fulfillment_status |
|---|---|---|---|---|---|---|---|---|
| 1 | 1 | 10 | 1 | 50.96 | 50.96 |
| order_item_id | order_id | product_id | quantity | unit_price | line_subtotal | tax_amount | discount_amount | fulfillment_status |
|---|---|---|---|---|---|---|---|---|
| 1 | 1 | 10 | 1 | 50.96 | 50.96 |
| order_item_id | quantity | line_subtotal | tax_amount | discount_amount | line_total | effective_unit_price |
|---|---|---|---|---|---|---|
| 1 | 1 | 50.96 | 4.14 | 0 | 55.10 | 55.10 |
| 2 | 3 | 601.53 | 53.20 | 0 | 654.73 |
| order_item_id | quantity | line_subtotal | tax_amount | discount_amount | line_total | effective_unit_price |
|---|---|---|---|---|---|---|
| 1 | 1 | 50.96 | 4.14 | 0 | 55.10 | 55.10 |
| 2 | 3 | 601.53 | 53.20 | 0 | 654.73 |
Showing first 5 of 123 rows.
Showing first 5 of 123 rows.
1. Data Selection:
2. Transformation:
3. Output:
1. Data Selection:
2. Transformation:
3. Output:
| 4.14 |
| 4.14 |
| 0.0 |
| 0.0 |
| shipped |
| shipped |
| 2 | 2 | 8 | 3 | 200.51 | 601.53 | 53.2 | 0.0 | delivered |
| 2 | 2 | 8 | 3 | 200.51 | 601.53 | 53.2 | 0.0 | delivered |
| 3 | 3 | 44 | 2 | 34.13 | 68.26 | 6.25 | 0.99 | shipped |
| 3 | 3 | 44 | 2 | 34.13 | 68.26 | 6.25 | 0.99 | shipped |
| 4 | 4 | 47 | 1 | 290.99 | 290.99 | 23.29 | 0.0 | shipped |
| 4 | 4 | 47 | 1 | 290.99 | 290.99 | 23.29 | 0.0 | shipped |
| 5 | 5 | 36 | 3 | 189.87 | 569.61 | 46.78 | 79.38 | backordered |
| 5 | 5 | 36 | 3 | 189.87 | 569.61 | 46.78 | 79.38 | backordered |
| 218.24 |
| 218.24 |
| 3 | 2 | 68.26 | 6.25 | 0.99 | 73.52 | 36.76 |
| 3 | 2 | 68.26 | 6.25 | 0.99 | 73.52 | 36.76 |
| 4 | 1 | 290.99 | 23.29 | 0 | 314.28 | 314.28 |
| 4 | 1 | 290.99 | 23.29 | 0 | 314.28 | 314.28 |
| 5 | 3 | 569.61 | 46.78 | 79.38 | 537.01 | 179 |
| 5 | 3 | 569.61 | 46.78 | 79.38 | 537.01 | 179 |