-1

I have a numpy.ndarray that is made up of other arrays all of the same length. For example:

array_1 = [[3,5,6.2],
           [2,4.1,10],
           [3,3.5,4]]

How can I get averages element wise. So as to return a single array where each element is the average of the respective elements across all the sub arrays in array_1? So it would return:

averaged_array = [2.66, 4.2, 6.733]

1 Answers1

0

to obtain the average for each list in the matrix:

averaged_array = np.array(array_1).mean(axis=1)

to obtain the average for each column:

averaged_array = np.array(array_1).mean(axis=0)