I have two datetime (Timestamp) formatted columns in my dataframe, df['start'], df['end']
. I'd like to get the duration between the two dates. So I create the duration column
df['duration'] = df['start'] - df['end']
However, now the duration
column is formatted as numpy.timedelta64
, instead of datetime.timedelta
as I would expect.
>>> df['duration'][0]
>>> numpy.timedelta64(0,'ns')
While
>>> df['start'][0] - df['end'][0]
>>> datetime.timedelta(0)
Can someone explain to me why the array subtraction change the timedelta
type? Is there a way that I keep the datetime.timedelta
as it is easier to work with?