Created
April 14, 2016 01:08
-
-
Save rashmibanthia/e35287e0462ac99a7d557308a63180d1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
#Convert timedelta to number of seconds | |
td = pd.to_timedelta ("22 days 04:37:08") | |
print(td," is ",(td / np.timedelta64(1, 's')).astype(int)," seconds") | |
#Convert seconds to hh:mm:ss | |
sec = 63914 | |
print(sec, " seconds is " ,pd.to_timedelta(sec, unit='s')) | |
#difference between two dates in seconds | |
a = pd.Timestamp('2015-09-22 01:20:44.551') | |
b = pd.Timestamp('2015-09-22 02:55:15.649') | |
print((b-a).seconds) | |
#difference | |
a = pd.Timestamp('02:30:10.917 18-09-2015') | |
b = pd.Timestamp('02:35:57.573 18-09-2015') | |
print((b-a).seconds) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment