Skip to content Skip to sidebar Skip to footer

Computing Numpy Array Mean Across Axis

I have a numpy array with shape: (16L, 360L, 720L) How do I find the mean so that the resulting array has the shape (16) i.e. I want mean of all 360 * 720 values for each of the 16

Solution 1:

What does

np.mean(arr, axis=(1,2)

produce?

From the mean docs

   axis : Noneorintortuple of ints, optional
        Axis or axes along which the means are computed. The default is to
        compute the mean of the flattened array.

        .. versionadded: 1.7.0

        If this is a tuple of ints, a mean is performed over multiple axes,
        instead of a single axis orall the axes as before.

Post a Comment for "Computing Numpy Array Mean Across Axis"