Have a dataframe that looks like this:
Unique_ID Due_Date Provider
0 731 3/05/2019 Optus Mobile Pty Ltd
1 733 3/05/2019 Optus Mobile Pty Ltd
2 747 23/04/2019 Optus Mobile Pty Ltd
3 747 21/04/2019 Optus Mobile Pty Ltd
4 747 17/04/2019 Optus Mobile Pty Ltd
I'd like to perform a pivot_table
to achieve the following:
Unique_ID Due_Date_1 Provider_1 Due_Date_2 Provider_2 Due_Date_3 Provider_3
0 731 3/05/2019 Optus Mobile Pty Ltd
1 733 3/05/2019 Optus Mobile Pty Ltd
2 747 23/04/2019 Optus Mobile Pty Ltd 21/04/2019 Optus Mobile Pty Ltd 17/04/2019 Optus Mobile Pty Ltd
I am trying somethinng like the following:
df.pivot_table(index=['Unique_ID'], columns='Due_Date', values='Provider')
but I am getting returned a bunch of errors.
pandas.core.base.DataError: No numeric types to aggregate
Note, this is a snippet of a much larger dataset, and there will be many Unique_ID
to perform on.
Do I need to perform a groupby
first?