Advertisement

TrimwebsolutionsTrimwebsolutions

Problem and Solutions

Elements corresponding to indices in Python ?

By M.K. Verma · 3 May 2022

Elements corresponding to indices in Python ?

First loop through Indices to get the row and column index i.e. i0 and i1 respectively and then get the value in A. Use this:

output = np.array([[A[i0][i1]] for i0, i1 in Indices])

Output:

array([[2.3],
   [1.4],
   [2.5]])