FunctionRacerProblemsRace

Price Range per Category

EasypandasPython

items has columns name, category and price. For each category, find the largest price minus the smallest price among its items. Return a dictionary mapping each category to that number.

Example 1

items {"name":["a","b","c"],"category":["toy","toy","book"],"price":[5,12,7]}
returns {"book":0,"toy":7}

toy: 12 - 5 = 7. book: 0.

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