@Anisha, Refer to the following code it may help.
>>> x = [1, 0, 3]
>>> z = np.max(x) + 1
>>> np.eye(z)[x]
array([[ 0., 1., 0., 0.],
[ 1., 0., 0., 0.],
[ 0., 0., 0., 1.]])
Alernatively, you can use:
>>> x = np.array([1, 0, 3])
>>> z= np.zeros((3, 4))
>>> z[np.arange(3), x] = 1
>>> y
array([[ 0., 1., 0., 0.],
[ 1., 0., 0., 0.],
[ 0., 0., 0., 1.]])