I have the following code, which constructs two matrices a (3*2 matrix of zeros) and b. I want to replace the 0s in matrix a with 1s depending on the index location stored in index b. I want to do it without a for loop.
import numpy as np
a = np.zeros((3, 2))
b = np.array([0, 1, 0])
The output should be
c = [[1, 0],
[0, 1],
[1, 0]]