np.mean () function

 1. The operation of the array:

Import numpy NP AS 
A = np.array ([[. 1, 2], [. 3,. 4 ]])
 Print (A)
 Print (type (A))
 Print (np.mean (A))
 Print (np.mean ( a, Axis = 0)) # Axis = 0, calculate the mean of each column 
Print (np.mean (a, Axis =. 1)) # calculate the mean of each row

2. Matrix operations

Import numpy AS NP 
num1 = np.array ([[l, 2,3], [2,3,4], [3,4, 5], [4,5,6 ]]) 

num2 = np.mat ( num1)
 Print (num2)
 Print (of the type (num2))
 Print (np.mean (num2)) # averaging all elements 
Print (np.mean (num2,0)) # compressed row, each column averaging 
Print ( np.mean (num2,1)) # compress columns, averaging for each line

 

Guess you like

Origin www.cnblogs.com/yibeimingyue/p/11413295.html