Say I have a numpy array x = np.array([0, 1, 2]), is there a built-in function in python so that I convert element to corresponding array?
e.g.
I want to convert 0 in x to [1, 0, 0], 1 to [0, 1, 0], 2 to [0, 0, 1], and the expected output is np.array([[1, 0, 0], [0, 1, 0], [0, 0, 1]]).
I tried x[x == 0] = np.array([1, 0, 0]) but it doesn't work.