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.
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])
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.