I have an array of the shape (100000, 1) with each element in an array of type positive integer and not greater than 6.
My goal is to convert each element into 1's and place these 1's in the new matrix of shape (100000, 6).
For example,
Input
X = np.array([[6],
[2],
[1],
...,
[5],
[4],
[3]])
# shape of X is (100000, 1)
Output
Y = np.array([[1, 1, 1, 1, 1, 1],
[1, 1, 0, 0, 0, 0],
[1, 0, 0, 0, 0, 0],
[ ... ],
[1, 1, 1, 1, 1, 0],
[1, 1, 1, 1, 0, 0],
[1, 1, 1, 0, 0, 0]])
# shape of Y is (100000, 6)
Is there any method that can achieve this without looping? Any help would be appreciated.
Select the correct answer from above options