title: Vectorizing a Pandas dataframe for Scikit-Learn
body: <p>Say I have a dataframe in Pandas like the following:</p>
  
  <pre><code>&gt; my_dataframe
  
  col1   col2
  A      foo
  B      bar
  C      something
  A      foo
  A      bar
  B      foo
  </code></pre>
  
  <p>where rows represent instances, and columns input features (not showing the target label, but this would be for a classification task), i.e. I trying to build <strong>X</strong> out of <code>my_dataframe</code>.</p>
  
  <p>How can I vectorize this efficiently using e.g. <a href="http://scikit-learn.org/stable/modules/feature_extraction.html#loading-features-from-dicts"><code>DictVectorizer</code></a> ?</p>
  
  <p>Do I need to convert each and every entry in my DataFrame to a dictionary first? (that's the way it is done in the example in the link above). Is there a more efficient way to do this?</p>