Created
March 27, 2019 02:22
-
-
Save nooperpudd/3c6fd7d239a00586e9ea7a209afe39e0 to your computer and use it in GitHub Desktop.
np_datetime64_to_timestamp
This file contains hidden or 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
def np_datetime64_to_timestamp(dt64, decimals=6): | |
""" | |
https://stackoverflow.com/questions/13703720/converting-between-datetime-timestamp-and-datetime64 | |
convert np.datetime64 to python datetime.timestamp | |
:return: timestamp | |
""" | |
value = (dt64 - np.datetime64("1970-01-01T00:00:00")) / np.timedelta64(1, 's') | |
return float(np.around(value, decimals=decimals)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment