Syntax error in pandas dataframe slice in my sklearn data prep? I'm new to sklearn and having trouble formatting the data to predict and evaluate a confusion matrix.  I'm using this Random Forest tutorial.

Here is my 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)


It's this line for my predictions which is giving me the error:

 preds = df[:6][clf.predict(test[features])]
 IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices
It is not possible to write numpy style slices in dataframe, like : 

observations = data[:6]


Try DataFrame.ix

df.ix[:,6:]


Cf panda indexing : Panda indexing