Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save blaylockbk/236fca4fd06fb45e5e0f7f5f73e15b51 to your computer and use it in GitHub Desktop.
Save blaylockbk/236fca4fd06fb45e5e0f7f5f73e15b51 to your computer and use it in GitHub Desktop.
this method uses numpy vectorized function, which is slightly faster than using a list generator
import numpy as np
import datetime
def datestr_to_datetime(x):
return datetime.datetime.strptime(x,'%Y-%m-%dT%H:%M:%SZ')
# where dates is some list of dates as a string...
# vectorize the function
converttime = np.vectorize(datestr_to_datetime)
DATES = converttime(dates)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment