sklearn DecisionTreeClassifier using strings that should be considered categorical
<p>I am training an <code>sklearn.tree.DecisionTreeClassifier</code>.  I start out with a <code>pandas.core.frame.DataFrame</code>.  Some of the columns of this data frame are strings that really should be categorical.  For example, 'Color' is one such column and has values such as 'black', 'white', 'red', and so on.  So I convert this column to be of type category like this:</p>

<pre><code>data['Color'] = data['Color'].astype('category')
</code></pre>

<p>This works just fine.  Now I split my data frame using <code>sklearn.cross_validation.train_test_split</code>, like this:</p>

<pre><code>X = data.drop(['OutcomeType'], axis=1)
y = data['OutcomeType']
X_train, X_test, y_train, y_test = train_test_split(X, y)
</code></pre>

<p>Now <code>X_train</code> has type <code>numpy.ndarray</code>.  However, the 'Color' values are no longer categorical, they are back to being strings.</p>

<p>So when I make the following calls:</p>

<pre><code>    clf = tree.DecisionTreeClassifier()
    clf = clf.fit(X_train, y_train)
</code></pre>

<p>I get the following error:</p>

<blockquote>
  <p>ValueError: could not convert string to float: Black</p>
</blockquote>

<p>What do I need to do to get this working correctly?</p>