If I define a structured array:
import numpy as np
x = np.array([(1, 'O', 1)],
dtype=np.dtype([('step', 'int32'),
('symbol', '|S1'),
('index', 'int32')]))
seems fine until I do this:
import numpy.lib.recfunctions as rec
rec.append_fields(x,'x',x['index']+1)
gives me
TypeError: object of type 'numpy.int32' has no len()
presumably because x.shape
is (1,) rather than (1,3). How do I append columns to this structured array?
Thanks all. On NumPy 1.4.1 this was giving me the error but I just upgraded to the git 2.0 version and it works fine.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.