I have a pandas dataframe structured like this:
+---------------+---------------------------+--------+
| Email | Paid at | Name |
+---------------+---------------------------+--------+
| john@mail.com | 2019-11-20 12:23:06 +0100 | #10710 |
| ed@mail.com | 2019-11-20 11:36:24 +0100 | #10709 |
| john@mail.com | 2019-11-19 14:58:41 +0100 | #10700 |
| ed@mail.com | 2019-11-19 14:41:30 +0100 | #10699 |
| dev@mail.com | 2019-11-19 14:20:26 +0100 | #10697 |
+---------------+---------------------------+--------+
And my final goal is to aggregate all the transactions made by one user, in a format like this one:
+---------------+---------------------------+--------+---------------------------+--------+--+
| Email | Paid at | Name | Paid at | Name | |
+---------------+---------------------------+--------+---------------------------+--------+--+
| john@mail.com | 2019-11-20 12:23:06 +0100 | #10710 | 2019-11-19 14:58:41 +0100 | #10700 | |
| ed@mail.com | 2019-11-20 11:36:24 +0100 | #10709 | 2019-11-19 14:41:30 +0100 | #10699 | |
| dev@mail.com | 2019-11-19 14:20:26 +0100 | #10697 | | | |
+---------------+---------------------------+--------+---------------------------+--------+--+
My starting dataframe has been constructed like this:
df = pd.DataFrame({'Email':['john@mail.com', 'ed@mail.com',
'john@mail.com', 'ed@mail.com', 'dev@mail.com'],
'Paid at':['2019-11-20 12:23:06 +0100',
'2019-11-20 11:36:24 +0100',
'2019-11-19 14:58:41 +0100',
'2019-11-19 14:41:30 +0100',
'2019-11-19 14:20:26 +0100'],
'Name':['#10710', '#10709', '#10700', '#10699', '#10697']})
I have tried using the pivot functions df.pivot(index='Email', columns='Name', values='Paid at')
and I can get a dataframe for which every timestamp is a column and the index in the email, but I am stuck in understanding how I can create the columns I want.