I have two arrays A and B. I have a list indices.
I want to locate each element of indices in A and print the corresponding values from B. I present the current and expected outputs.
import numpy as np
A=np.array([[ 0, 4],
[ 0, 5],
[1,6]])
B=np.array([[9.16435586e-05],
[1.84193464e-14],
[1.781909182e-5]])
indices= [[0,4],[1,6]]
for i in range(0,len(indices)):
A=indices[i]
print(A)
The current output is:
[0, 4]
[1, 6]
The expected output is:
[[0,4],[1,6]]
[[9.16435586e-05],[1.781909182e-5]]
B. How could you expect to print its values???B.indices= [[0,4],[1,6]]contains slices ofA, not indices[0,4]fromindicesinAand print the corresponding value fromBi.e.[9.16435586e-05]. Similarly, for[1,6].