[PYTHON] Sum of multiple numpy arrays (sum)

Sum of numpy array (sum)

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

Sum of multiple numpy arrays (sum)
Examine any combination of values in multiple arrays
[Python] Takes representative values ​​of multiple images [Numpy]
About cumulative assignment of lists and numpy arrays
Multiple inheritance of classes
About all of numpy
Copy of multiple List
Set function of NumPy
Get the sum of each of multiple columns with awk
Catch multiple types of exceptions
Sorting of multidimensional associative arrays
Optimal placement of multiple images
python> Handling of 2D arrays
Install multiple versions of Python
About all of numpy (2nd)
[Scientific / technical calculation by Python] Basic operation of arrays, numpy
Handle numpy arrays with f2py
Visualization of matrix created by numpy
[ev3dev × Python] Control of multiple motors
Project Euler 10 "Sum of Prime Numbers"
Rewrite piecewise of NumPy for CuPy
[Memo] Small story of pandas, numpy
Extract multiple elements with Numpy array