How can I make a python numpy arange of datetime

后端 未结 5 1941
挽巷
挽巷 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条回答
  •  萌比男神i
    2020-12-09 02:13

    Note that @nneonneo solution can be simplified in

    result = first_date + np.arange(24) * datetime.timedelta(hours=1)
    

    thanks to NumPy array manipulations. The result array has then a dtype=object.

    For more complex ranges, you might be interested in the scikits.timeseries package (no longer maintained) or better, the pandas package that reimplemented most of the ideas of scikits.timeseries. Both packages support older versions of NumPy (1.5, 1.6...)

提交回复
热议问题