Created
April 4, 2018 17:48
-
-
Save vn-ki/28edbc581b1218118b40df29855d1c6c 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
from astropy.time import Time | |
def convert_dt64_to_Time(dt64): | |
if dt64.dtype.name in ['datetime64[M]', 'datetime64[Y]']: | |
dt64 = dt64.astype('M8[D]') | |
time_string = str(dt64) | |
precision = 3 | |
if '.' in time_string: | |
precision = len(time_string.split('.')[-1]) | |
return Time(time_string, precision=precision) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment