时间索引问题

时间:2016-10-17 20:30:27

标签: python python-2.7

我有以下代码

import datetime
#import numpy as np
import jacks_toolbox.getHistoricalData as dt


# ------------------------------------------------------------------------------
# Config
# ------------------------------------------------------------------------------
rolling_time = 15
num_days = 20

Start = "2016-09-27 00:00:00"
End = "2016-10-14 23:00:00"

settleTimeStr = "2016-10-14 14:00:00"

# ------------------------------------------------------------------------------
# Start execution
# ------------------------------------------------------------------------------
# Get a window of data from MySQL and plot it
startTime  = datetime.datetime.strptime(Start, "%Y-%m-%d %H:%M:%S")
endTime    = datetime.datetime.strptime(End, "%Y-%m-%d %H:%M:%S")
settleTime = datetime.datetime.strptime(settleTimeStr, "%Y-%m-%d %H:%M:%S")

print "Start time: " + startTime.strftime("%Y-%m-%d %H:%M:%S")
print "End time: " + endTime.strftime("%Y-%m-%d %H:%M:%S")
print "Settle time: " + settleTime.strftime("%Y-%m-%d %H:%M:%S")

data = dt.getHistoricalDataByTime(startTime, endTime, 5)
settles = dt.getHistoricalDataByTime(startTime, settleTime, 5)

print settles[::1425]

我正在尝试对其进行索引,以便从我的开始时间开始每24小时打印一次,但目前正在打印以下内容:

Start time: 2016-09-27 00:00:00
End time: 2016-10-14 23:00:00
Settle time: 2016-10-14 14:00:00
Inst                     7_year        UBZ6
2016-09-27 00:00:00   99.735491  183.839583
2016-09-28 00:00:00   99.906250  185.593750
2016-09-29 00:00:00   99.714375  184.936422
2016-09-30 00:00:00  100.012908  186.308594
2016-10-03 00:00:00   99.596467  184.013021
2016-10-04 00:00:00   99.450893  183.697917
2016-10-05 00:01:00   99.109375  181.457386
2016-10-06 00:01:00   98.953804  180.645833
2016-10-07 00:01:00   98.761837  180.049107
2016-10-10 00:01:00         NaN  179.682292
2016-10-11 00:31:00   98.584375  178.619318
2016-10-12 00:31:00   98.501563  178.125000
2016-10-13 00:31:00   98.799342  179.251042
2016-10-14 00:31:00   98.687500  178.328125

出于某种原因,这是我加入一分钟,然后是30分钟,我试图将其编入索引,我不知道为什么会这样。最初我从1440开始,因为那是24 * 60,但注意到第一组时间是15分钟,所以我转到1425,这就是我得到的。任何帮助/建议将不胜感激。

0 个答案:

没有答案