title: Numpy one hot encoder is only displaying huge arrays with zeros
body: <p>I have a <code>(400, 1)</code> numpy array that has values such <code>4300, 4450, 4650...</code> where these values can be distributed around 20 classes i.e. <code>4300 class 1, 4450 class 2...</code> and tried the below code to transform that array to one hot encoded list. The <code>y_train_onehot</code> is showing a list of 400 arrays where each array has a size > 4000 i.e. each array has around 4000 zeros. How can I fix that in order to have one hot encoded vectors for each value i.e. <code>4300</code> can be <code>00001</code>.</p>
  
  <pre><code>def convertOneHot(data):
      y=np.array([int(i[0]) for i in data])
      y_onehot=[0]*len(y)
      for i,j in enumerate(y):
          y_onehot[i]=[0]*(y.max() + 1)
          y_onehot[i][j]=1
      return (y,y_onehot)
  
  y_train,y_train_onehot = convertOneHot(data)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/LvPqs.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LvPqs.jpg" alt="sample from y_train_onehot"></a></p>