Given:
ts = pd.to_datetime(['2014-01-08 08:00:42',
'2014-01-08 08:01:00',
'2014-01-08 08:01:12'])
Is there a prescribed way to get a result that is the timedelta (preferably total_seconds
attribute) between each element?
What I have now seems overly verbose:
pd.Index((pd.Series(ts) - pd.Series(ts).shift())).total_seconds()
# Float64Index([nan, 18.0, 12.0], dtype='float64')
I don't really care about the resulting data structure type, be it a list, Index, or Series.