我有基于分钟的OHLCV数据,用于打开范围/第一个小时(9:30-10:30 AM EST)。我正在寻找重新采样这个数据,所以我可以得到一个60分钟的值,然后计算范围。重采样分钟数据
当我调用数据的dataframe.resample()函数时,我得到两行,最初的行从上午9:00开始。我期待着从上午9:30开始只有一排。
注意:最初的数据从9:30开始。
编辑:添加代码:
# Extract data for regular trading hours (rth) from the 24 hour data set
rth = data.between_time(start_time = '09:30:00', end_time = '16:15:00', include_end = False)
# Extract data for extended trading hours (eth) from the 24 hour data set
eth = data.between_time(start_time = '16:30:00', end_time = '09:30:00', include_end = False)
# Extract data for initial balance (rth) from the 24 hour data set
initial_balance = data.between_time(start_time = '09:30:00', end_time = '10:30:00', include_end = False)
卡住了试图通过个别日期分隔开度范围内,并获得初始余额
conversion = {'Open' : 'first', 'High' : 'max', 'Low' : 'min', 'Close' : 'last', 'Volume' : 'sum'}
sample = data.between_time(start_time = '09:30:00', end_time = '10:30:00', include_end = False)
sample = sample.ix['2007-05-07']
sample.tail()
sample.resample('60Min', how = conversion)
默认情况下重新取样开始于小时的开始。我希望它从数据开始的地方开始。
如果您复制和粘贴文本,而不是使用图像:) – 2013-02-13 19:07:12