title: Converting multiple columns to categories in Pandas. apply?
body: <p>Consider a Dataframe. I want to convert a set of columns <code>to_convert</code> to categories. </p>
  
  <p>I can certainly do the following:</p>
  
  <pre><code>for col in to_convert:
    df[col] = df[col].astype('category')
  </code></pre>
  
  <p>but I was surprised that the following does not return a dataframe:</p>
  
  <pre><code>df[to_convert].apply(lambda x: x.astype('category'), axis=0)
  </code></pre>
  
  <p>which of course makes the following not work:</p>
  
  <pre><code>df[to_convert] = df[to_convert].apply(lambda x: x.astype('category'), axis=0)
  </code></pre>
  
  <p>Why does <a href="http://pandas.pydata.org/pandas-docs/dev/generated/pandas.DataFrame.apply.html" rel="noreferrer"><code>apply</code></a> (<code>axis=0</code>) return a Series even though it is supposed to act on the columns one by one? </p>