Python generate dates series

前端 未结 3 1536
北荒
北荒 2020-12-29 02:37

How can i generate array with dates like this:

Timestamps in javascript miliseconds format from 2010.12.01 00:00:00 to 2010.12.12.30 23.59.59 with step 5 minutes.

3条回答
  •  佛祖请我去吃肉
    2020-12-29 03:09

    I just felt that it might be worthwhile to note that pandas also has this functionality. Depending on what case you are dealing with exactly, pandas might be a worthy tool to invest time in.

    import pandas as pd 
    times = pd.date_range('2012-10-01', periods=289, freq='5min')
    

    This returns a pandas timeseries-index. Which can be converted to numpy arrays.

    np.array(times)
    

提交回复
热议问题