Understanding the numpy's conversion of datetime64 to int64

Viewed 28

I have a an array containing some dates:

import numpy as np

dates = np.arange('2005-01', '2005-12', dtype='datetime64[M]')

print(dates)

['2005-01' '2005-02' '2005-03' '2005-04' '2005-05' '2005-06' '2005-07'
 '2005-08' '2005-09' '2005-10' '2005-11']

When I do:

dates.astype(np.int64)

I get:

array([420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430])

What are these numbers? I specifically want to know whether every year-month has a unique code like these?

I read Datetimes and Timedeltas but I could not find any information about how numpy converts datetime64 to integers.

0 Answers
Related