Hello, I have the following array:
matriz = np.array([
[5, 5, 5],
[5, 5, 5],
[10, 10, 10]
])
I need the result with an array of their respective means, like this:
[6.66, 6.66, 6.66]
Thankful
Hello, I have the following array:
matriz = np.array([
[5, 5, 5],
[5, 5, 5],
[10, 10, 10]
])
I need the result with an array of their respective means, like this:
[6.66, 6.66, 6.66]
Thankful
Using the numpy.average
function you can calculate the average of the array
values for a given axis.
Ex:
matriz = np.array([
[5, 5, 5],
[5, 5, 5],
[10, 10, 10]
])
#media para o eixo Y
media = np.average(matriz, axis=0)
Output from variable media
:
[6.66666667 6.66666667 6.66666667]
At documentation you can see better about the parameters.