'Adding a multidimensional numpy array into one array

I have a multidimensional numpy array that has the shape (5, 6192, 1) so essentially 5 arrays of length 6192 into one array.

How could I add the elements of all the arrays into one array of length 6192 in the following way. For example if the 5 arrays look like

ar1 = [1,2,3...]
ar2 = [1,2,3...]
ar3 = [1,2,3...]
ar4 = [1,2,3...]
ar5 = [1,2,3...]

I want my final array to look like:

ar = [5,10,15,...]

So for each inner array, add the values of each same position into a new value for the final array that is the sum of all the values in this position.

The shape should be, I guess shape(1,6192,1).



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source