Classification of continious data
<p>I've got a Pandas df that I use for Machine Learning in Scikit for Python.
One of the columns is a target value which is continuous data (varying from -10 to +10).</p>

<p>From the target-column, I want to calculate a new column with 5 classes where the number of rows per class is the same, i.e. if I have 1000 rows I want to distribute into 5 classes with roughly 200 in each class.</p>

<p>So far, I have done this in Excel, separate from my Python code, but as the data has grown it's getting unpractical.</p>

<p>In Excel I have calculated the percentiles and then used some logic to build the classes.</p>

<p>How to do this in Python?</p>

<p>Cannot get this to work. </p>

<p>Anybody know how to do this in qcut instead? </p>

<p>I have tried the following: 
df['5D'] = pd.qcut(df['target'], 5, labels=None, retbins=True, precision=3)
(5D is a new column with class 1-5 and target is a column in a dataframe.</p>

<p>I get the following error: ValueError: Length of values does not match length of index</p>

python scikit-learn percentile