“”""
多维数组-最大最小平均值、求和
“”"
import numpy as np
n1 = np.random.randint(0,150,size=(2,4,5))
print(n1)
运行结果:
[[[144 132 99 140 19]
[122 12 37 109 24]
[143 96 71 110 80]
[ 79 107 116 90 38]]
[[ 84 146 112 117 110]
[ 99 113 7 113 66]
[120 28 103 77 76]
[ 95 66 22 139 83]]]
print(n1.max(axis=0))
运行结果:
[[144 146 112 140 110]
[122 113 37 113 66]
[143 96 103 110 80]
[ 95 107 116 139 83]]
print(n1.min(axis=1))
运行结果:
[[22 53 39 30 1]
[16 82 53 4 29]]
print(n1.mean(axis=2))
运行结果:
[[ 85.8 66.8 85. 90.6]
[ 29.8 98.2 109.2 91.6]]
print(n1.sum(axis=0))