title: pandas DF from numpy structured array: can't get unicode or string type for column (only object)
body: <p>I pull data out of a software system, which gives me a numpy structured array. I convert this to a pandas DataFrame to do work and then need to convert it back to a structured array so I can push it back into the original system. String/text data shows up in the array as a unicode column and gets described as an object in the DF. Been trying to figure out how to get it back to either unicode or string, either in the DF or even the ending array, but having trouble. In the interest of asking a single question, how do I get a DF column dtype to be unicode/string?</p>
  
  <p>Here's what I'm trying, the column 'region' is the one I'm focusing on:</p>
  
  <pre><code>import pandas as pd
  import numpy as np
  arr = array([(1, u'01', 7733855, 0), (2, u'01', 7733919, 1244),
         (3, u'01', 7732571, 1236), (4, u'01', 7732387, 1234),
         (5, u'01', 7733327, 1239), (6, u'01', 7733755, 1241),
         (7, u'01', 7732571, 1236), (8, u'01', 7733923, 0),
         (9, u'01', 7733327, 1239), (10, u'01', 7733755, 1241)], 
        dtype=[('hru_id_nat', '&lt;i4'), ('region', '&lt;U255'), ('POI_ID', '&lt;i4'), ('hru_segment', '&lt;i4')])
  </code></pre>
  
  <p>Then I can make into a DF:</p>
  
  <pre><code>df = pd.DataFrame(arr)
  df.dtypes
  </code></pre>
  
  <p>shows that 'region' has an <code>object</code> dtype:</p>
  
  <pre><code>hru_id_nat      int32
  region         object
  POI_ID          int32
  hru_segment     int32
  dtype: object
  </code></pre>
  
  <p>I try to specify the dtypes when converting to DF, but not quite getting it:</p>
  
  <pre><code>n = list(arr.dtype.names)
  t = [i[0].name for i in arr.dtype.fields.values()]
  dt = [(i, j) for i, j in zip(n, t)]
  dt
  </code></pre>
  
  <p>gets: </p>
  
  <pre><code>[('hru_id_nat', 'int32'),
   ('region', 'unicode8160'),
   ('POI_ID', 'int32'),
   ('hru_segment', 'int32')]
  </code></pre>
  
  <p>This throws an error when I try to use the dt specification to create the DF</p>
  
  <pre><code>df = pd.DataFrame(arr, dt)
  </code></pre>
  
  <p>doesn't help if I try these:</p>
  
  <pre><code>dt[1] = ('region', 'unicode')
  dt[1] = ('region', 'str')
  dt[1] = ('region', np.str)
  </code></pre>
  
  <p>I've also tried <code>convert_type()</code> (based on <a href="https://stackoverflow.com/questions/21197774/assign-pandas-dataframe-column-dtypes">this post</a>) and <code>df['region'] = df['region'].astype(np.str)</code> (based on <a href="https://stackoverflow.com/questions/25180694/pandas-convert-column-of-unicodes-to-column-of-list-of-strings">this post</a>), but neither seem to change the dtype reported by the DF.</p>
  
  <p>Thanks much for any input.</p>