title: Pandas: convert categories to numbers
body: <p>Suppose I have a dataframe with countries that goes as:</p>
  
  <pre><code>cc | temp
  US | 37.0
  CA | 12.0
  US | 35.0
  AU | 20.0
  </code></pre>
  
  <p>I know that there is a pd.get_dummies function to convert the countries to 'one-hot encodings'. However, I wish to convert them to indices instead such that I will get <code>cc_index = [1,2,1,3]</code> instead. </p>
  
  <p>I'm assuming that there is a faster way than using the get_dummies along with a numpy where clause as shown below:</p>
  
  <p><code>[np.where(x) for x in df.cc.get_dummies().values]</code></p>
  
  <p>This is somewhat easier to do in R using 'factors' so I'm hoping pandas has something similar.</p>