我正在尝试使用现有数组的元素创建一个新数组。我不断收到:ValueError: Setting void-array with object members using buffer。
import numpy as np
import datetime
date = datetime.date(2013, 4, 5)
results = [(date,0,1,2,3), (date,5,1,5,6), (date,3,4,4,7)]
stock_dt = np.dtype([('date', object),
('open', np.int8),
('high', np.int8),
('low', np.int8),
('close', np.int8)])
d = np.array(results, dtype=stock_dt)
matches = []
for item in d:
if item['high'] == 1:
matches.append(item)
rec = np.array(matches, dtype=stock_dt)
print rec