title: Convert array of string (category) to array of int from a pandas dataframe
body: <p>I am trying to do something very similar to that <a href="https://stackoverflow.com/questions/3172509/numpy-convert-categorical-string-arrays-to-an-integer-array">previous question</a> but I get an error.
  I have a pandas dataframe containing features,label I need to do some convertion to send the features and the label variable into a machine learning object:</p>
  
  <pre><code>import pandas
  import milk
  from scikits.statsmodels.tools import categorical
  </code></pre>
  
  <p>then I have:</p>
  
  <pre><code>trainedData=bigdata[bigdata['meta']&lt;15]
  untrained=bigdata[bigdata['meta']&gt;=15]
  #print trainedData
  #extract two columns from trainedData
  #convert to numpy array
  features=trainedData.ix[:,['ratio','area']].as_matrix(['ratio','area'])
  un_features=untrained.ix[:,['ratio','area']].as_matrix(['ratio','area'])
  print 'features'
  print features[:5]
  ##label is a string:single, touching,nuclei,dust
  print 'labels'
  
  labels=trainedData.ix[:,['type']].as_matrix(['type'])
  print labels[:5]
  #convert single to 0, touching to 1, nuclei to 2, dusts to 3
  #
  tmp=categorical(labels,drop=True)
  targets=categorical(labels,drop=True).argmax(1)
  print targets
  </code></pre>
  
  <p>The output console yields first:</p>
  
  <pre><code>features
  [[ 0.38846334  0.97681855]
  [ 3.8318634   0.5724734 ]
  [ 0.67710876  1.01816444]
  [ 1.12024943  0.91508699]
  [ 7.51749674  1.00156707]]
  labels
  [[single]
  [touching]
  [single]
  [single]
  [nuclei]]
  </code></pre>
  
  <p>I meet then the following error:</p>
  
  <pre><code>Traceback (most recent call last):
  File "/home/claire/Applications/ProjetPython/projet particule et objet/karyotyper/DAPI-Trainer02-MILK.py", line 83, in &lt;module&gt;
  tmp=categorical(labels,drop=True)
  File "/usr/local/lib/python2.6/dist-packages/scikits.statsmodels-0.3.0rc1-py2.6.egg/scikits/statsmodels/tools/tools.py", line 206, in categorical
  tmp_dummy = (tmp_arr[:,None]==data).astype(float)
  AttributeError: 'bool' object has no attribute 'astype'
  </code></pre>
  
  <p>Is it possible to convert the category variable 'type' within the dataframe into int type ? 'type' can take the values 'single', 'touching','nuclei','dusts' and I need to convert with int values such 0, 1, 2, 3.</p>