1
나는 다음과 같은 정렬 NumPy와 배열Pytables 테이블 DTYPE 정렬
import numpy as np
import tables as pt
numrows = 10
dt = np.dtype([('date', [('year', '<i4'), ('month', '<i4'), ('day', '<i4')]),
('apples', '<f8'),
('oranges', '|S7'),
('pears', '<i4')], align=True)
x = np.zeros(numrows, dtype=dt)
for d in x.dtype.descr:
print d
를 작성하고 dtype.descr
나는 다음과 같은 얻을 인쇄 할 경우 :
('date', [('year', '<i4'), ('month', '<i4'), ('day', '<i4')])
('', '|V4')
('apples', '<f8')
('oranges', '|S7')
('', '|V1')
('pears', '<i4')
DTYPE은 포함이 여분의 빈 공간 '| V4 ','| V1 '
이제이 동일한 dtype (Numpy flavor)을 사용하여 Pytable-> 테이블을 만들면 정렬이 손실되는 것 같습니다.
h5file = pt.open_file('mytable.h5', mode='w')
table = h5file.create_table('/', 'mytable', dt, filters=None, expectedrows=numrows, byteorder='little')
policy = table.row
for j in xrange(numrows):
for field in table.colnames:
if (field == 'date'):
policy[field] = (2014, 1, 8)
else:
policy[field] = 0
policy.append()
table.flush()
mytable = h5file.root.mytable[:]
h5file.close()
for d in mytable.dtype.descr:
print d
의 출력은 없다 : 더 이상
('date', [('year', '<i4'), ('month', '<i4'), ('day', '<i4')])
('apples', '<f8')
('oranges', '|S7')
('pears', '<i4')
'| V'공간 내가 Pytable-을 만들 수있는 방법
>는 정렬 (보존되도록 표는이 '유지 | V '공백)?