FunctionRacerProblemsRace

Two Best per Team

MediumpandasPython

players has columns name, team and score. For each team, take the two players with the highest scores (or just one if the team has only one player). Ties in score are broken by name, alphabetically. Return a dictionary mapping each team to the list of those names, best first.

Example 1

players {"name":["a","b","c","d"],"team":["x","x","x","y"],"score":[5,9,7,1]}
returns {"x":["b","c"],"y":["d"]}

x: b (9), c (7). y: d.

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