I have the following dataset:
ID | Name | Stages | Date |
---|---|---|---|
1 | John | Interview | 02/01/2022 |
2 | Mario | Apply | 01/01/2022 |
3 | Luis | Interview | 02/01/2022 |
2 | Mario | Interview | 02/01/2022 |
2 | Mario | Offer | 03/01/2022 |
3 | Luis | Offer | 03/01/2022 |
and I want to make it look like this:
ID | Name | Apply | Interview | Offer |
---|---|---|---|---|
1 | John | NaN | 02/01/2022 | NaN |
2 | Mario | 01/01/2022 | 02/01/2022 | 03/01/2022 |
3 | Luis | NaN | 02/01/2022 | 03/01/2022 |
df = df.reset_index()
df.pivot( index = ['index','Name'],columns = ['Stages'], values = 'Dates')
This shows the dates by stage, but it doesn't group by Name and I've been stuck trying other stuff.