Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/340.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 计算横轴上的numpy阵列平均值_Python_Numpy - Fatal编程技术网

Python 计算横轴上的numpy阵列平均值

Python 计算横轴上的numpy阵列平均值,python,numpy,Python,Numpy,我有一个形状为的numpy数组: (16L、360L、720L) 如何找到平均值,以使生成的数组具有形状(16),即,我需要16个轴元素中每个元素的所有360*720值的平均值 我试过这个: np.mean(arr, axis=0) 但是那是以(360*720)的形式出现的,那是什么呢 np.mean(arr, axis=(1,2) 生产 从平均值文档 axis : None or int or tuple of ints, optional Axis or axes

我有一个形状为的numpy数组:

(16L、360L、720L)

如何找到平均值,以使生成的数组具有形状
(16)
,即,我需要16个轴元素中每个元素的所有360*720值的平均值

我试过这个:

np.mean(arr, axis=0)
但是那是以
(360*720)

的形式出现的,那是什么呢

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

平均值
文档

   axis : None or int or tuple 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 or all the axes as before.

你为什么不尝试一些更简单的方法来观察结果呢?>>a=np.arange(24)。重塑(2,3,4),然后使用>>>np.mean(a,axis=0)将轴变为0,1,2,你可以做轴=(0,1)或(0,2),(1,2)和(0,1,2)等轴的组合,这将为你提供可能的平均值形状