1

I am trying to get

[[ 4.    0.   0. ]
 [ 8.    0.  0.  ]]

out of this:

[[ 2.    0.5   0.  ]
 [ 2.    0.25  0.  ]]

So I want to divide the first column by the second one:

div = arr[:,0]/arr[:,1] but don't know what's the best way to reshape and add zeros to get the result.

Thanks in advance.

1 Answer 1

3

If you want to do it in place, you could do

a[:, 0] = a[:, 0] / a[:, 1]
a[:, 1] = 0

If not

b = np.zeros(6).reshape(2, 3)
b[:, 0] = (a[:, 0] / a[:, 1])
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.