fork download
  1. import numpy as np
  2.  
  3. x = np.arange(12).reshape(3, 4)
  4.  
  5. print(x)
  6. print(np.mean(x, axis=0, keepdims=True))
  7. print(np.mean(x, axis=-1, keepdims=True))
Success #stdin #stdout 0.18s 27236KB
stdin
Standard input is empty
stdout
[[ 0  1  2  3]
 [ 4  5  6  7]
 [ 8  9 10 11]]
[[4. 5. 6. 7.]]
[[1.5]
 [5.5]
 [9.5]]