我正在嘗試添加一個列。在
這是我的代碼:import numpy
import numpy.lib.recfunctions
data=[[20140101,'a'],[20140102,'b'],[20140103,'c']]
data_array=numpy.array(data)
data_dtype=[('date',int),('type','|S1')]
data_rec=numpy.core.records.array(list(tuple(data_array.transpose())), dtype=data_dtype)
data_rec.date
data_rec.type
#Here, i will just try to make another field called copy_date that is a copy of the date , just as an example
y=numpy.lib.recfunctions.append_fields(data_rec,'copy_date',data_rec.date,dtypes=data_rec.date.dtype,usemask=False)
現在看看輸出
^{pr2}$
y不再是一種>>> type(data_rec)
我似乎失去了記錄能力,也就是通過屬性調用字段。
如何正确地将列添加到記錄中并能夠調用字段?在
另外,如果有人能告訴我上面代碼中usemask選項的作用,我會很高興的。在
謝謝