Apologies if this is an easy one but I can’t see anything in the numpy
documentation. I have a datetime64
and I’d like to find out which day of the week it is.
Unlike python datetime
, datetime64
doesn’t seem to have a .weekday()
function. However it does have a busday_offset()
function, which implies it must know behind-the-scenes what day of the week a given date is. Any help greatly appreciated.
Advertisement
Answer
I think you could do in this way:
import numpy as np import datetime t = '2018-09-19' t = np.datetime64(t) day = t.astype(datetime.datetime).isoweekday() print day
Output:
3