I have a dataframe as follows:
| people | statusName |
| -------------------- | ----------- |
| [Steve] | To Do |
| [Jill, John] | To Do |
| [Jill, John] | To Do |
| [Jill, John] | Completed |
| [Amanda, John] | To Do |
| [Meryll, Jill, John] | To Do |
| [Meryll, Jill, John] | In Progress |
| [Meryll, Bill] | Completed |
| [John, Tim] | To Do |
| [John, Tim] | To Do |
| [John, Tim] | Assigned |
| [John, Tom] | In Progress |
So the first column is a list type. I want to sort them according to the different statusName for each person. So the desired dataframe is as follows:
| people | Total | To Do | In Progress | Completed | Stopped |
|--------|-------|-------|-------------|-----------|---------|
| Steve | 1 | 1 | 0 | 0 | 0 |
| Jill | 5 | 3 | 1 | 1 | 0 |
| John | 6 | 4 | 1 | 1 | 0 |
| Amanda | 1 | 1 | 0 | 0 | 0 |
| Meryll | 3 | 1 | 1 | 1 | 0 |
| Bill | 1 | 0 | 0 | 1 | 0 |
| Tim | 3 | 2 | 0 | 0 | 1 |
| Tom | 1 | 0 | 1 | 0 | 0 |
So basically what I want is how crosstab function works when the people column is a string and not a list type of different people names.
How can I achieve the same using dataframe? Or whichever method is applicable in this case?
Dataframe:
df = pd.DataFrame({'people': {0: ['Steve'],
1: ['Jill', 'John'],
2: ['Jill', 'John'],
3: ['Jill', 'John'],
4: ['Amanda', 'John'],
5: ['Meryll', 'Jill', 'John'],
6: ['Meryll', 'Jill', 'John'],
7: ['Meryll', 'Bill'],
8: ['John', 'Tim'],
9: ['John', 'Tim'],
10: ['John', 'Tim'],
11: ['John', 'Tom']},
'statusName': {0: 'To Do',
1: 'To Do',
2: 'To Do',
3: 'Completed',
4: 'To Do',
5: 'To Do',
6: 'In Progress',
7: 'Completed',
8: 'To Do',
9: 'To Do',
10: 'Assigned',
11: 'In Progress'}})