I have an array with the following shape (7352, 128, 6)
How can I get the "mean" of the 1st and 2nd dimensions with NumPy in Python?
The resulting shape of the "means" I want to obtain is (1, 6).
I have an array with the following shape (7352, 128, 6)
How can I get the "mean" of the 1st and 2nd dimensions with NumPy in Python?
The resulting shape of the "means" I want to obtain is (1, 6).
You can do:
np.mean(x, axis=(0, 1))
You resulting shape would be (6,) though.
numpy.mean()
with axis argument is proper solution.
import numpy as np
x = np.random.rand(7352, 128, 6)
x_mean = np.mean(x, axis=(0, 1))
print(x_mean.shape) # -> (6,)