title: Programmatically add column names to numpy ndarray
body: <p>I'm trying to add column names to a numpy ndarray, then select columns by their names.  But it doesn't work.  I can't tell if the problem occurs when I add the names, or later when I try to call them.</p>
  
  <p>Here's my code.</p>
  
  <pre><code>data = np.genfromtxt(csv_file, delimiter=',', dtype=np.float, skip_header=1)
  
  #Add headers
  csv_names = [ s.strip('"') for s in file(csv_file,'r').readline().strip().split(',')]
  data = data.astype(np.dtype( [(n, 'float64') for n in csv_names] ))
  </code></pre>
  
  <p>Dimension-based diagnostics match what I expect:</p>
  
  <pre><code>print len(csv_names)
  &gt;&gt; 108
  print data.shape
  &gt;&gt; (1652, 108)
  </code></pre>
  
  <p>"print data.dtype.names" also returns the expected output.</p>
  
  <p>But when I start calling columns by their field names, screwy things happen.  The "column" is still an array with 108 columns...</p>
  
  <pre><code>print data["EDUC"].shape
  &gt;&gt; (1652, 108)
  </code></pre>
  
  <p>... and it appears to contain more missing values than there are rows in the data set.</p>
  
  <pre><code>print np.sum(np.isnan(data["EDUC"]))
  &gt;&gt; 27976
  </code></pre>
  
  <p>Any idea what's going wrong here?  Adding headers should be a trivial operation, but I've been fighting this bug for hours.  Help!</p>