How can I make a python numpy arange of datetime

后端 未结 5 1962
挽巷
挽巷 2020-12-09 01:48

I have some input data, with timestamps in the input file in the form of hours from the date time specified in the filename.

This is a bit useless, so I need to conv

5条回答
  •  星月不相逢
    2020-12-09 02:08

    With modern NumPy you can do this:

    np.arange(np.datetime64('2017-01-01'), np.datetime64('2017-01-08'))
    

    And it gives you:

    array(['2017-01-01', '2017-01-02', '2017-01-03', '2017-01-04',
           '2017-01-05', '2017-01-06', '2017-01-07'], dtype='datetime64[D]')
    

提交回复
热议问题