I have a dataframe and it shows the types as
signup_time 151112 non-null datetime64[ns]
purchase_time 151112 non-null datetime64[ns]
The actual values are in the format 2015-02-24 22:55:49
When I subtract two rows I get the difference in days like 52 days 03:51:22
how can I get the difference values in seconds
1) Use .dt.total_seconds()
(df.purchase_time - df.signup_time).dt.total_seconds()
2) Or use np.timedelta64(1, 's')
(df.purchase_time - df.signup_time) / np.timedelta64(1, 's')
3) Or use .astype('timedelta64[s]')
(df.purchase_time - df.signup_time).astype('timedelta64[s]')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With