Python numpy how to do one hot encoding

import numpy as np
c = 6 # number of classes
y = np.random.randint(0,5,[1,10])

print y
[[1 1 4 3 2 4 4 4 4 2]]
y_one_hot_encoded = np.eye(c)[y]

print  y_one_hot_encoded
[[[ 0.  1.  0.  0.  0.  0.]
  [ 0.  1.  0.  0.  0.  0.]
  [ 0.  0.  0.  0.  1.  0.]
  [ 0.  0.  0.  1.  0.  0.]
  [ 0.  0.  1.  0.  0.  0.]
  [ 0.  0.  0.  0.  1.  0.]
  [ 0.  0.  0.  0.  1.  0.]
  [ 0.  0.  0.  0.  1.  0.]
  [ 0.  0.  0.  0.  1.  0.]
  [ 0.  0.  1.  0.  0.  0.]]]