0
假設我有以下PyTable列描述符:訂貨在PyTable表嵌套結構的
import numpy as np
import tables as pt
class Date_t(pt.IsDescription):
year = pt.Int32Col(shape=(), dflt=2013, pos=0)
month = pt.Int32Col(shape=(), dflt=1, pos=1)
day = pt.Int32Col(shape=(), dflt=1, pos=2)
class Info(pt.IsDescription):
col1 = pt.Int32Col(shape=(), dflt=0, pos=0)
startdate = Date_t()
birthdate = Date_t()
col2 = pt.Int32Col(shape=(), dflt=0, pos=3)
enddate = Date_t()
col3 = pt.Int32Col(shape=(), dflt=0, pos=5)
col4 = pt.Int32Col(shape=(), dflt=0, pos=6)
如何指定「開始日期」,「出生日期」和「結束日期」的位置?
我想我可以做這樣的事情:
startdate = Date_t(pos=1)
birthdate = Date_t(pos=2)
,並重新定義Date_t類爲:
class Date_t(pt.IsDescription):
def __init__(self, pos):
self._v_pos = pos
year = pt.Int32Col(shape=(), dflt=2013, pos=0)
month = pt.Int32Col(shape=(), dflt=1, pos=1)
day = pt.Int32Col(shape=(), dflt=1, pos=2)
但是這給我的錯誤:
類型錯誤:對象。 新()不參數
任何想法?