0

I have a 10x10 numpy matrix and I have a list containing indices of elements I want to query.

matrix = np.zeros((10, 10), dtype=int)

indices = [[2,3], [3,4]]

the issue I'm facing is, what I actually want is the element matrix[2,3] but matrix[indices[0]] gives a different output because the latter actually means matrix[[2,3]]. the output is 2 different rows.

How do I get around this problem?

1

1 Answer 1

1

I ended up finding a solution.

storing the indices as tuples inside of a list works

indices = [(2,3), (3,4)] and then matrix[indices[0]] gives the desired output

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.