FunctionRacerProblemsRace

Median per Group

EasypandasPython

items has columns group and value. Return a dictionary mapping each group to the median of its values (the middle value, or the average of the two middle values when the count is even), as floats.

Example 1

items {"group":["a","a","a","b","b"],"value":[1,9,5,2,4]}
returns {"a":5.0,"b":3.0}

a: 5.0. b: (2 + 4) / 2 = 3.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