0

When using matrix in numpy, I want to change the value of one element in a matrix using the index, but the result I got is strange.

How can I change one value in indexing method?

arr = np.array([[1, 2, 3, 4], [5, 6, 7, 8]])
mat1 = np.mat(arr)
mat1[1][0] = 3
print(arr)

[[1 2 3 4]
 [3 3 3 3]]

1 Answer 1

2

Do the following change:

mat1[1][0] = 3 -> mat1[1,0] = 3

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.