0

If there is a numpy array that is a list of 2d arrays, is there more efficient way than calling the mean function twice?

z = np.array([[[0, 0, 0],
               [10, 10, 10]],
              [[0, 0, 0],
               [5, 5, 5]],
              [[0, 0, 0],
               [2, 2, 2]]])
print(z.mean(axis=2).mean(axis=1))
>[ 5.   2.5  1. ]
dranobob
  • 796
  • 1
  • 5
  • 19

0 Answers0