I have a df as:
Name Date Time
A 02/20/2021 12:30:06
A 02/20/2021 12:30:20
A 02/21/2021 12:30:20
A 02/22/2021 02:30:30
i am trying to combine them into one datetime and subtract current row with previous to get the difference columns of datetime in seconds like:
Name Date Time diff
A 02/20/2021 12:30:06
A 02/20/2021 12:30:20 14 seconds
A 02/21/2021 12:30:20 86400 seconds
A 02/22/2021 02:30:30 50410 seconds
I am trying this:
df['Datetime'] = df['Date'].astype(str)+' '+df['Time'].astype(str)
df[['diff']] = df.groupby('Name')[['Datetime', 'Result']].diff()
But it is giving me output as 0 days 00:00:10.I am not able to find proper solution anywhere.thanks in advance