FunctionRacerProblemsRace

Revenue per Product

MediumpandasPython

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

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More pandas problems