fork download
  1. # Python 2.7
  2. import datetime, numpy as np
  3. import calendar
  4.  
  5. def toTimestamp(d):
  6. return calendar.timegm(d.timetuple())
  7.  
  8. arr1 = np.array([toTimestamp(datetime.datetime(2008,1,d)) for d in range(1,10)])
  9. arr2 = np.arange(1,10)
  10.  
  11. result = np.interp(toTimestamp(datetime.datetime(2008,1,5,12)),arr1,arr2)
  12. print result # Prints 5.5
Runtime error #stdin #stdout #stderr 0.01s 119552KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "prog.py", line 2, in <module>
    import datetime, numpy as np
ImportError: No module named numpy