I'm looking for a function analogous to np.interp
that can work with datetime
objects.
For example:
import datetime, numpy as np
arr1 = np.array([datetime.datetime(2008,1,d) for d in range(1,10)])
arr2 = np.arange(1,10)
np.interp(datetime.datetime(2008,1,5,12),arr1,arr2)
would ideally return 5.5
, but numpy
raises TypeError: array cannot be safely cast to required type
. Is there a nice pythonic way around this?