I have a numpy array, A of size nx1 where each value is a number between 0 and 9.
I would like to create a new array, B of size nx10 such that in B[i] we store a numpy array that contains zeros and a 1 in position A[i].
For example:
A array
[[9]
 [2]
 [4]
 [1]
 [8]]
B array
[[0, 0, 0, 0, 0, 0, 0, 0, 0, 1]
 [0, 0, 1, 0, 0, 0, 0, 0, 0, 0]
 [0, 0, 0, 0, 1, 0, 0, 0, 0, 0]
 [0, 1, 0, 0, 0, 0, 0, 0, 0, 0]
 [0, 0, 0, 0, 0, 0, 0, 0, 1, 0]]
Is there an elegant way of doing this with numpy?
 
     
     
    