Python IndexError: only integers
<p>I'm new to sklearn and having trouble formatting the data to predict and evaluate a confusion matrix.  I'm using this <a href="http://blog.yhat.com/posts/random-forests-in-python.html" rel="nofollow noreferrer">Random Forest tutorial</a>.</p>

<p>Here is my code</p>

<pre><code>from sklearn.ensemble import RandomForestClassifier
import numpy as np
import pandas as pd

dataframe = pd.read_csv('output.txt', sep='\t')
df = pd.DataFrame(dataframe)
df['is_train'] = np.random.uniform(0, 1, len(df)) &lt;= .75
train, test = df[df['is_train']==True], df[df['is_train']==False]
features = df.columns[1:5]
clf = RandomForestClassifier(n_jobs=2)
y, _ = pd.factorize(train['event_count'])
clf.fit(train[features], y)
</code></pre>

<p>This line for my predictions gives the error:</p>

<pre><code>preds = df['event_count'][clf.predict(test[features])]
IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices
</code></pre>