Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- df_children_debt = df[['children', 'debt', 'family_status']]
- df_pivot = df_children_debt.pivot_table(index ='children', columns = 'debt', values = 'family_status', aggfunc ='count')
- df_pivot
- #ВЫВОД:
- debt 0 1
- children
- 0 13132.0 1064.0
- 1 4374.0 444.0
- 2 1929.0 202.0
- 3 303.0 27.0
- 4 37.0 4.0
- 5 9.0 NaN
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement