[Numpy-discussion] How to create structured char arrays?
Bruce Southey
bsouthey at gmail.com
Mon Apr 4 15:01:10 EDT 2011
Hi,
I think that I have resolved my issue down to creating a structured
string array.
I am using numpy version '2.0.0.dev-3c338cb'.
Without a structured array, it should be a 2 by 2 array:
>>> np.array([('a','b'),('c','d')])
array([['a', 'b'],
['c', 'd']],
dtype='|S1')
>>> np.array([('a','b'),('c','d')], dtype='a2')
array([['a', 'b'],
['c', 'd']],
dtype='|S2')
It does not work as a structured array:
>>> np.array([('a','b'),('c','d')], dtype=[('label','a2'), ('Value',
'a4')])
array([('a', 'b'), ('c', 'd')],
dtype=[('label', '|S2'), ('Value', '|S4')])
What is the correct dtype argument to use in this case?
Thanks
Bruce
More information about the NumPy-Discussion
mailing list