I have a dataframe with some clock in/clock out times that looks like this:
                  Date In/Out       Id
0  2020-11-04 14:25:25     In   912907
1  2020-11-04 14:25:43     In  1111111
2  2020-11-04 14:26:20    Out  1111111
3  2020-11-04 14:26:29    Out   912907
4  2020-11-05 14:25:25     In   912907
5  2020-11-05 14:26:29    Out   912907
I would like to transform it to look like this:
In/Out       Id                   In                  Out
0       1111111  2020-11-04 14:25:43  2020-11-04 14:26:20
1        912907  2020-11-04 14:25:25  2020-11-04 14:26:29
2        912907  2020-11-05 14:25:25  2020-11-05 14:26:29
I've tried pivoting on Id, but the repeated Id is causing a ValueError. How can I accomplish this?
import pandas
df = pandas.DataFrame(data={
    'Date':['2020-11-04 14:25:25','2020-11-04 14:25:43','2020-11-04 14:26:20','2020-11-04 14:26:29','2020-11-05 14:25:25','2020-11-05 14:26:29'],
    'In/Out':['In','In','Out','Out','In','Out'],
    'Id':['912907','1111111','1111111','912907','912907','912907']
})
print(df)
print(df.drop(index=[4,5]).pivot(index='Id',columns='In/Out',values='Date').reset_index())
try:
    print(df.pivot(index='Id',columns='In/Out',values='Date').reset_index())
except ValueError:
    print('ValueError: Index contains duplicate entries, cannot reshape')
 
    