Код: Выделить всё
import numpy as np
arr = np.array([[1,2,3], [1,2,3]])
< /code>
>>> arr
array([[1, 2, 3],
[1, 2, 3]])
>>> arr.shape
(2, 3)
< /code>
Since arr.shape[0]
>>> np.mean(arr, axis=0)
array([1., 2., 3.]) # Mean of each column
>>> np.mean(arr, axis=1)
array([2., 2.]) # Mean of each row
< /code>
In the documentation, the "axis" parameter is described as:
"Axis or axes along which the means are computed."
I initially assumed that axis=0 будет вычислять по строке, что означает возвращение среднего значения для каждой строки, потому что arr.shape [0] представляет строки.
Я использую Python 3.10.0 и Numpy версии 2.2.3
Я понимаю неправильную документацию? Почему Axis = 0 ряды коллапсов вместо столбцов?
Подробнее здесь: https://stackoverflow.com/questions/794 ... ad-of-rows