title: python - Initialize an empty array with named columns (and data types)
body: <p>I have three constraints, and, as usual, I can only figure out how to satisfy any two of them at the same time:</p>
  
  <ol>
  <li>Multi-dimensional array</li>
  <li>Named columns</li>
  <li>Different columns include different data types (so everything in col 1 is a string, but col 2 is all Decimal, etc.)</li>
  </ol>
  
  <p>I'm currently using numpy ndarrays to store my data with different types in each column. I've initialized the array so it can store multiple data types:</p>
  
  <pre><code>norm = numpy.empty((79, len(header)), dtype=numpy.object)
  </code></pre>
  
  <p>I've been using a header (a list of string names) as a proxy for column names (and then looking up the index of the values in the header) but this seems really cludgy.</p>
  
  <p>I've looked around but as far as I can tell, when you initialize an array with column names (and types) you have to fill the array with values as you do so, as in: <a href="https://stackoverflow.com/questions/5795748/store-numpy-row-and-column-headers">Store NumPy Row and Column Headers</a></p>
  
  <p>Because when I try something like this:</p>
  
  <pre><code>n=numpy.empty((5,2), dtype=[("sub", "str"), ("words", Decimal)])
  n[0] = ['06', Decimal(10)]
  </code></pre>
  
  <p>I get this error:</p>
  
  <pre><code>Traceback (most recent call last):
  File "&lt;string&gt;", line 1, in &lt;fragment&gt;
  ValueError: Setting void-array with object members using buffer.
  </code></pre>