简体   繁体   中英

convert datetime datetime to numpy int64 python

How do I convert type datetime.datetime to type numpy.int64? I have 44346 days, 0:00:00 but I want 44346

data_r = xlrd.xldate_as_datetime(int(data_calcolo), 0).date()
    y = data_r.month
    a= data_r.year
    if k > 12 :
       k= k-12
       y =y-k
       a = a-1  
    data_nuova=datetime(a, y, 1)
    z=datetime(1900, 1, 1)
    f=(data_nuova-z)

Subtracting two datetime.datetime objects (ie, data_nuova-z ) returns a datetime.timedelta object.

If you just want the number of days in that difference, then you can access it using f.days and then cast that integer to an np.int64 object.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM