title: Convert categorical data in pandas dataframe
body: <p>I have a dataframe with this type of data (too many columns):</p>
  <pre><code>col1        int64
  col2        int64
  col3        category
  col4        category
  col5        category
  </code></pre>
  <p>Columns look like this:</p>
  <pre><code>Name: col3, dtype: category
  Categories (8, object): [B, C, E, G, H, N, S, W]
  </code></pre>
  <p>I want to convert all the values in each column to integer like this:</p>
  <pre><code>[1, 2, 3, 4, 5, 6, 7, 8]
  </code></pre>
  <p>I solved this for one column by this:</p>
  <pre><code>dataframe['c'] = pandas.Categorical.from_array(dataframe.col3).codes
  </code></pre>
  <p>Now I have two columns in my dataframe - old <code>col3</code> and new <code>c</code> and need to drop old columns.</p>
  <p>That's bad practice. It works but in my dataframe there are too many columns and I don't want do it manually.</p>
  <p>How can I do this more cleverly?</p>