On Wed, May 18, 2011 at 8:56 PM, Robert Love <[email protected]>wrote:
>
> my_list = [[1960, 'W0'],[2001, 'D5']]
>
> my_arr = np.array(my_list, dtype=('uint', '|S2'))
>
> gives me an error I don't understand:
>
> ValueError: mismatch in size of old and new data-descriptor
>
> What are the old and new? I get the same problem if try np.asarray()
>
> If I make the dtype ('|S4', '|S4') I can read in as strings without
> errors
>
> How do I convert a list of mixed types to a structured array?
>
> Thanks for any pointers.
>
my_list = [(1960, 'W0'),(2001, 'D5')] # tuples inside
my_arr = np.array(my_list, dtype='uint, |S2') # one dtype string
_______________________________________________
NumPy-Discussion mailing list
[email protected]
http://mail.scipy.org/mailman/listinfo/numpy-discussion