'How can I count cumulative variables in pandas, but split the results into different columns?
For example, my dataset has a column that specifies a user's sex, I want to create two separate columns that each cumulatively count the occurrence of each sex.
User - Sex
1 0
2 1
3 1
4 0
I want to turn the above into the table below where males are 0 and females are 1.
User - Sex - Male Count - Female Count
1 0 0 0
2 1 1 0
3 1 1 1
4 0 1 2
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
