<div dir="ltr">Hi Kirill,<div><br></div><div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small;display:inline">​T​</div>he idea is that each tuple assigns a name to the field and a data type.  There are a variety of ways to create structured arrays but they all involve giving both a name and data type to each field (I think).  See <a href="https://docs.scipy.org/doc/numpy/user/basics.rec.html">https://docs.scipy.org/doc/numpy/user/basics.rec.html</a><br><br></div><div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">​Jon​</div></div><div><br></div><div>On Fri, Mar 24, 2017 at 5:09 AM,  <<a href="mailto:numpy-discussion-request@python.org">numpy-discussion-request@python.org</a>> wrote:<br>> From: Kirill Balunov <<a href="mailto:kirillbalunov@gmail.com">kirillbalunov@gmail.com</a>><br>> To: <a href="mailto:numpy-discussion@scipy.org">numpy-discussion@scipy.org</a><br>> Cc:<br>> Bcc:<br>> Date: Thu, 23 Mar 2017 21:16:28 +0300<br>> Subject: [Numpy-discussion] Structured array creation with list of lists and others<br>> 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.<br>><br>> It took me some time (really, much more than some), to understand the problem with structured array creation. As example:<br>><br>> I had list of list of this kind:<br>> b=[[ 1, 10.3, 12.1, 2.12 ],...]<br>><br>> And tried:<br>> np.array(b, dtype='i4,f4,f4,f4')<br>><br>> Which raises some weird exception:<br>> TypeError: a bytes-like object is required, not 'int'<br>><br>> 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...<br>><br>> 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 ...?<br>><br>> Also the exception does not help at all...<br>> p.s.: It looks like that dtype also accepts only list of tuples. But I can not catch the idea for this restrictions.<br><br><br><br><br>-- <br>________________________________________________________<br>Jonathan D. Slavin                 Harvard-Smithsonian CfA<br><a href="mailto:jslavin@cfa.harvard.edu">jslavin@cfa.harvard.edu</a>       60 Garden Street, MS 83<br>phone: (617) 496-7981       Cambridge, MA 02138-1516<br>cell: (781) 363-0035             USA<br>________________________________________________________<br></div></div>