NumPy笔记:统计指标((max,min,std,mean,argmax,sum))
import numpy as np a = np.linspace(1, 16, 16).reshape(4, 4) print("a:", a) print("max:", np.max(a, axis=1)) # axis 0-列 1-行 print("min:", np.min(a, axis=0)) # axis 0-列 1-行 print("std:", np.std(a, axis=0)) # axis 0-列 1-行 print("mean:", np.mean(a, axis=0)) # axis 0-列 1-行 print("argmax:", np.argmax(a, axis=1)) # axis 0-列 1-行 print("sum:", np.sum(a, axis=1)) # axis 0-列 1-行
a: [[ 1. 2. 3. 4.] [ 5. 6. 7. 8.] [ 9. 10. 11. 12.] [13. 14. 15. 16.]] max: [ 4. 8. 12. 16.] min: [1. 2. 3. 4.] std: [4.47213595 4.47213595 4.47213595 4.47213595] mean: [ 7. 8. 9. 10.] argmax: [3 3 3 3] sum: [10. 26. 42. 58.]