title: python dict to numpy structured array
body: <p>I have a dictionary that I need to convert to a NumPy structured array.  I'm using the arcpy function <a href="http://resources.arcgis.com/en/help/main/10.1/index.html#//018w00000016000000" rel="noreferrer"><code>NumPyArraytoTable</code></a>, so a NumPy structured array is the only data format that will work.  </p>
  
  <p>Based on this thread: <a href="https://stackoverflow.com/questions/10838982/writing-to-numpy-array-from-dictionary">Writing to numpy array from dictionary</a> and this thread: <a href="https://stackoverflow.com/questions/7471872/how-to-convert-python-dictionary-object-to-numpy-array">How to convert Python dictionary object to numpy array</a></p>
  
  <p>I've tried this:</p>
  
  <pre><code>result = {0: 1.1181753789488595, 1: 0.5566080288678394, 2: 0.4718269778030734, 3: 0.48716683119447185, 4: 1.0, 5: 0.1395076201641266, 6: 0.20941558441558442}
  
  names = ['id','data']
  formats = ['f8','f8']
  dtype = dict(names = names, formats=formats)
  array=numpy.array([[key,val] for (key,val) in result.iteritems()],dtype)
  </code></pre>
  
  <p>But I keep getting <code>expected a readable buffer object</code></p>
  
  <p>The method below works, but is stupid and obviously won't work for real data. I know there is a more graceful approach, I just can't figure it out.</p>
  
  <pre><code>totable = numpy.array([[key,val] for (key,val) in result.iteritems()])
  array=numpy.array([(totable[0,0],totable[0,1]),(totable[1,0],totable[1,1])],dtype)
  </code></pre>