I have the following arrays:
example_array = [[0,0,0,0,0],[0,0,0,0,0],[0,0,0,0,0],[0,0,0,0,0],[0,0,0,0,0],[0,0,0,0,0],[0,0,0,0,0]]
indexes = [[1,2,3], [2,3], [0,4,2], [1,4,3], [0,4,3], [1,2,3], [1,2]]
I would like to replace the elements in the example_array with 1 according to the index in indexes. So, the expected result should be this:
example_array = [[0,1,1,1,0],[0,0,1,1,0],[1,0,1,0,1],[0,1,0,1,1],[1,0,0,1,1],[0,1,1,1,0],[0,1,1,0,0]].
I tried different approaches, for example to use pandas, like this:
matrix = pd.DataFrame(example_array)
for row in matrix:
for i in indexes:
for j in i:
x_u.iloc[x, j] = 1
but it doesn't give me the hoped results! The solution does not need to use pandas library. Thanks for the help!