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)
但是这给我的错误:
类型错误:对象。 新()不参数
任何想法?