Teams Side by Side
people has columns name and team; names are all different. Return a DataFrame with one column per team, the team names in alphabetical order. Each column lists that team's names alphabetically from the top. Columns shorter than the longest one end with None.
Example 1
people {"name":["Kim","Abe","Zed","Lou","Bea","Moe"],"team":["red","blue","red","blue","red","green"]}
returns {"columns":["blue","green","red"],"rows":[["Abe","Moe","Bea"],["Lou",null,"Kim"],[null,null,"Zed"]]}
blue has Abe and Lou, green only Moe, red has Bea, Kim and Zed. The shorter columns are filled with None.
Constraints
1 <= len(people) <= 40- 1 to 4 teams
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More pandas problems
- Three Month TotalsHard
- Winner of Each GroupHard
- Adult NamesBeginner
- Average AgeBeginner
- Biggest Daily JumpBeginner
- Cap the SalariesBeginner
- Carry the Last ValueBeginner
- Colour TallyBeginner