[Numpy-discussion] Importing a list into a structured numpy array, what is my error?

Robert Love rblove_lists at comcast.net
Wed May 18 21:56:14 EDT 2011


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.



More information about the NumPy-Discussion mailing list