It was the first time I tried to create a structured array in numpy. Usually I use pandas for heterogeneous arrays, but it is one more dependency to my project.
It took me some time (really, much more than some), to understand the problem with structured array creation. As example: I had list of list of this kind: b=[[ 1, 10.3, 12.1, 2.12 ],...] And tried: np.array(b, dtype='i4,f4,f4,f4') Which raises some weird exception: TypeError: a bytes-like object is required, not 'int' Two hours later I found that I need list of tuples. I didn't find any help in documentation and could not realize that the problem with the inner lists... Why there is such restriction - 'list of tuples' to create structured array? What is the idea behind that, why not list of lists, or tuple of lists or ...? Also the exception does not help at all... p.s.: It looks like that dtype also accepts only list of tuples. But I can not catch the idea for this restrictions.
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org https://mail.scipy.org/mailman/listinfo/numpy-discussion