title: How do I import data with different types from file into a Python Numpy array?
body: <p>Say I have a file <code>myfile.txt</code> containing:</p>
  
  <pre><code>1   2.0000  buckle_my_shoe
  3   4.0000  margery_door
  </code></pre>
  
  <p><strong>How do I import data from the file to a numpy array as an int, float and string?</strong></p>
  
  <p>I am aiming to get:</p>
  
  <pre><code>array([[1,2.0000,"buckle_my_shoe"],
  [3,4.0000,"margery_door"]])
  </code></pre>
  
  <p>I've been playing around with the following to no avail:</p>
  
  <pre><code>a = numpy.loadtxt('myfile.txt',dtype=(numpy.int_,numpy.float_,numpy.string_))
  </code></pre>
  
  <p>EDIT: Another approach might be to use the ndarray type and convert afterwards. </p>
  
  <pre><code>b = numpy.loadtxt('myfile.txt',dtype=numpy.ndarray)
  
      array([['1', '2.0000', 'buckle_my_shoe'],
         ['3', '4.0000', 'margery_door']], dtype=object)
  </code></pre>