You can do this using timedelta:
import pandas as pd
import datetime
data = {'t1':['01:15:31',
'00:47:15'],
't2':['01:13:02',
'00:51:33']
}
def make_delta(entry):
h, m, s = entry.split(':')
return datetime.timedelta(hours=int(h), minutes=int(m), seconds=int(s))
df = pd.DataFrame(data)
df = df.applymap(lambda entry: make_delta(entry))
df['elapsed'] = df['t1'] + df['t2']
In [23]: df
Out[23]:
t1 t2 elapsed
0 01:15:31 01:13:02 02:28:33
1 00:47:15 00:51:33 01:38:48
Edit: I see you need to do this by column, not row. In that case do the same thing, but:
In [24]: df['t1'].sum()
Out[24]: Timedelta('0 days 02:02:46')
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…