Crosstab Counts
people has columns dept and level (both text). Return a dictionary that maps each department to a dictionary mapping every level in the table to how many people of that department have it (0 if none).
Example 1
people {"dept":["it","it","hr"],"level":["senior","junior","junior"]}
returns {"hr":{"junior":1,"senior":0},"it":{"junior":1,"senior":1}}
it: junior 1, senior 1. hr: junior 1, senior 0.
Constraints
- The tables are small
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More pandas problems
- Customers Who Bought EverythingMedium
- Date Range FilterMedium
- Deepest Fall per TickerMedium
- Department HeadcountMedium
- Earning More Than the ManagerMedium
- Employee BonusMedium
- Employee DepartmentsMedium
- Find Valid EmailsMedium