FunctionRacerProblemsRace

Middle Earners

HardpandasPython

staff has columns id, company and salary. Line up each company's people by salary, and by id where salaries are equal. Return the ids of the people in the middle of each line: one person when the company has an odd number of people, the two middle people when it has an even number. Sort the ids from low to high.

Example 1

staff {"id":[1,2,3,4,5,6,7],"company":["A","A","A","B","B","B","B"],"salary":[50,20,90,70,10,40,40]}
returns [1,6,7]

A in order is 2, 1, 3: the middle is 1. B in order is 5, 6, 7, 4 (6 and 7 both earn 40, lower id first): the middle two are 6 and 7.

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