import numpy as np
m = 7
dz = np.array([1,2,23,45,6,78,9])
db = np.sum(dz)/m
print(db)
输出结果:
23.428571428571427
import numpy as np
A = np.array([[56.0,0.0,4.4,68.0],
[1.2,104.0,52.0,8.0],
[1.8,135.0,99.0,0.9]])
print(A)
输出结果:
[[ 56. 0. 4.4 68. ]
[ 1.2 104. 52. 8. ]
[ 1.8 135. 99. 0.9]]
cal= A.sum(axis=0)
print(cal)
输出:
[ 59. 239. 155.4 76.9]
percentage = 100*A/cal.reshape(1,4)
print(percentage)
输出:
[[94.91525424 0. 2.83140283 88.42652796]
[ 2.03389831 43.51464435 33.46203346 10.40312094]
[ 3.05084746 56.48535565 63.70656371 1.17035111]]