Premium problem148. Cross-Tabulate Two Columns

Easy Locked

survey has columns gender and purchased, where purchased holds "yes" or "no".

Return the contingency table: rows indexed by gender, one column per purchased value, cells holding how many respondents fall in each combination. Both axes sorted ascending, as pandas produces them.

Input

  gender purchased
0      f       yes
1      f        no
2      m       yes
3      m       yes
4      m        no
5      f       yes

Output

purchased  no  yes
gender            
f           1    2
m           1    2

Premium problem

This one's part of Premium. Unlock the full Pandas track plus every other premium problem on the site.

Implement solve(...)