2
A = np.array([[1,2,3],[4,1,3],[6,7,1]])

array([[1, 2, 3],
       [4, 1, 3],
       [6, 7, 1]])

I need to transform every 1 to a 23 but only on a subset of the array. I want to start at the index 1:1 and stop at 2:2

array([[1, 2, 3],
       [4, 23, 3],
       [6, 7, 23]])
1
  • What's the code for your search function? Commented Mar 9, 2015 at 16:48

1 Answer 1

3
>>>A = np.array([[1,2,3],[4,1,3],[6,7,1]])
array([[1, 2, 3],
       [4, 1, 3],
       [6, 7, 1]])

>>>b = A[1:,1:]==1
>>>A[1:,1:][b]=23
>>>A
array([[ 1,  2,  3],
       [ 4, 23,  3],
       [ 6,  7, 23]])
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.