python-广播

(m,n)+(1,n),会使(1,n)复制成(m,n)再进行相加

例如:

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)
cal=A.sum(axis=0)
print(cal)
percentag=100*A/cal
print(percentag)



[[94.91525424  0.          2.83140283 88.42652796]
 [ 2.03389831 43.51464435 33.46203346 10.40312094]
 [ 3.05084746 56.48535565 63.70656371  1.17035111]]

猜你喜欢

转载自blog.csdn.net/smj20170417/article/details/80908726