np mean about axis

Solutions on MaxInterview for np mean about axis by the best coders in the world

showing results for - "np mean about axis"
Rachel
29 Jan 2020
1arr = [[14, 17, 12, 33, 44],  
2       [15, 6, 27, 8, 19], 
3       [23, 2, 54, 1, 4, ]] 
4    
5# mean of the flattened array 
6print("\nmean of arr, axis = None : ", np.mean(arr)) 
7
8mean of arr, axis = None :  18.6
9  
10# mean along the axis = 0 
11print("\nmean of arr, axis = 0 : ", np.mean(arr, axis = 0)) 
12
13mean of arr, axis = 0 :  [17.33333333  8.33333333 31.         14.         22.33333333]
14
15# mean along the axis = 1 
16print("\nmean of arr, axis = 1 : ", np.mean(arr, axis = 1))
17
18mean of arr, axis = 1 :  [24.  15.  16.8]