I have an array of shape (100000, 1) with each element in the array is a positive integer and not greater than 6.
My goal is to convert each element into ones and place these ones in a 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.