Revenue per Product
sales has columns product and qty (units sold in one sale). prices has columns product and price (one row per product, covering every product in sales). Return a dictionary mapping each product that was sold to its revenue: the sum over its sales of qty * price.
Example 1
sales {"product":["pen","cup","pen"],"qty":[2,1,3]}
prices {"product":["cup","pen"],"price":[5,2]}
returns {"cup":5,"pen":10}
pen: 5 * 2 = 10. cup: 5.
Constraints
- The tables are small
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More pandas problems
- Rising TemperatureMedium
- Salespeople Without Red OrdersMedium
- Three in a RowMedium
- Top Earners per DepartmentMedium
- Two Best per TeamMedium
- Visits per UserMedium
- Bought Together MostHard
- Cancelled Share per DayHard