I have a column in my dataframe formatted like 11/24/2020 7:09:45. I would like to create another column that is the delta in seconds between the previous row and current row. I may be making this way more complicated than it needs to be.
import pandas as pd
import numpy as np
df
run run_ts
11:02 11/30/2020 7:24:00
10:11 11/30/2020 7:23:00
16:08 11/30/2020 7:35:00
14:33 11/30/2020 7:32:00
14:27 11/30/2020 7:25:45
14:26 11/30/2020 7:25:25
14:25 11/30/2020 7:25:10
14:24 11/30/2020 7:24:55
NaaN 11/30/2020 7:24:15
NaaN 11/30/2020 7:24:30
df['timeDiff'] = np.where(df['run'] == "NaaN", df['run_ts'].shift(1)-df['run_ts']), "")
TypeError: unsupported operand type(s) for -: 'str' and 'str'
I am not certain which direction to take this. Thanks for the help!