2016-05-07 79 views
1

我想創建一個時間範圍,每2.5分鐘創建一個樣本,我知道樣本的開始時間和數量。使用Pandas創建每分鐘的日期時間範圍

這裏是代碼得到1000個時間戳通過5分鐘至一個給定的天開始分離:

date = pandas.date_range(datetime(2015, 12, 25, hour=12, minute=0), 
         periods=1000, freq='5min') 

如何指定一個2分30秒的頻率?

回答

1

2min30S作爲freq PARAM:

In [9]: 
pandas.date_range(datetime(2015, 12, 25, hour=12, minute=0), periods=1000, freq='2min30S') 
Out[9]: 
DatetimeIndex(['2015-12-25 12:00:00', '2015-12-25 12:02:30', 
       '2015-12-25 12:05:00', '2015-12-25 12:07:30', 
       '2015-12-25 12:10:00', '2015-12-25 12:12:30', 
       '2015-12-25 12:15:00', '2015-12-25 12:17:30', 
       '2015-12-25 12:20:00', '2015-12-25 12:22:30', 
       ... 
       '2015-12-27 05:15:00', '2015-12-27 05:17:30', 
       '2015-12-27 05:20:00', '2015-12-27 05:22:30', 
       '2015-12-27 05:25:00', '2015-12-27 05:27:30', 
       '2015-12-27 05:30:00', '2015-12-27 05:32:30', 
       '2015-12-27 05:35:00', '2015-12-27 05:37:30'], 
       dtype='datetime64[ns]', length=1000, freq='150S') 

或者150S還將努力

相關問題