Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我仍然掌握使用 numpy 和数组操作的窍门。
我正在寻找获取二维数组列表的逐行平均值的方法。
例如,我有一个 4x3x25 数组,我希望得到一个 3x25 的行平均值数组。
如果一切都在一个 3D 阵列中,您可以这样做:
A.mean(axis=0)
…它将沿第一维运行。
如果它实际上只是 2D 数组的列表,则必须先将其转换为 3D 数组。我会做:
A = np.dstack(list_of_arrays) # Combine the 2D arrays along a new 3rd dimension A.mean(axis=2) # Calculate the means along that new dimension