I want to add multiple (two or more) arrays to get the total for each element. numpy has a numpy.sum function, but this function can't be used because it calculates the sum of all the elements in the array or the sum of each row or column (I thought, but in the comments) If you did as you pointed out, you could do it lol). After thinking a little, I tried using the default sum function and it worked normally.
>>> import numpy as np
>>> hoge = np.array([1,2,3])
>>> sum([hoge,hoge,hoge])
array([3,6,9])
Of course, you can think of it as an implementation that simply adds the elements inside, but ...
Ah, but you can't `sum ([" a "," b "," c "])`
. Apparently, it seems that the implementation is to add to 0
.
(I tried it with python2.7.13, so I don't know if it's 3 series.)
Recommended Posts