title: How to use KBinsDiscretizer to make continuous data into bins in Sklearn?
body: <p>I am working on a ML algorithm in which I tried to convert the continuous target values into small bins to understand the problem better. Hence to make better prediction. My original problem is for regression but I convert into classification by making small bins with labels. </p>
  
  <p>I did as follow,</p>
  
  <pre><code>from sklearn.preprocessing import KBinsDiscretizer  
  est = KBinsDiscretizer(n_bins=3, encode='ordinal', strategy='uniform')
  s = est.fit(target) 
  Xt = est.transform(s)
  </code></pre>
  
  <p>It shows a value error like below. Then I reshaped my data into 2D. yet I could not solve it.</p>
  
  <blockquote>
    <p>ValueError: Expected 2D array, got 1D array instead:</p>
  </blockquote>
  
  <pre><code>from sklearn.preprocessing import KBinsDiscretizer
  
  myData = pd.read_csv("train.csv", delimiter=",")
  target = myData.iloc[:,-5]  # this is a continuous data which must be 
                          # converted into bins with a new column.
  
  xx = target.values.reshape(21263,1)
  
  est = KBinsDiscretizer(n_bins=3, encode='ordinal', strategy='uniform')
  s = est.fit(xx) 
  Xt = est.transform(s)
  </code></pre>
  
  <p>You can see my target has 21263 rows. I have to divide these into 10 equal bins and write it into a a new column in my dataframe. Thanks for the guidance.</p>
  
  <p>P.S.: 
  Max target value:185.0<br>
  Min target value:0.00021</p>