Home > other >  The difference between pandas Timedelta and timedelta64[ns]?
The difference between pandas Timedelta and timedelta64[ns]?

Time:01-02

I want to use the function total_seconds.

I obtain the difference between two dates by subtracting the beginning from the end.

df["diff"] = (df["End"] - df["Start"])

which yields:

0      0 days 00:12:08
1      0 days 00:18:56
2      0 days 00:17:17
3      0 days 00:48:46
4      0 days 00:21:02
             ...      
7015   0 days 00:14:32
7016   0 days 00:08:33
7017   0 days 00:19:38
7018   0 days 00:18:41
7019   0 days 00:37:35
Name: diff, Length: 7020, dtype: timedelta64[ns]

There is a function The timedelta types available are listed

You realize only .astype('timedelta64[ns]') leave the outcome of any datetime substration in the format 0 days 00:12:08. Even picosecond (.astype('timedelta64[ps]')) which is much less that nanosecond gets converted

  • Related