Answers for "np.mean about axis"

0

np.mean about axis

arr = [[14, 17, 12, 33, 44],  
       [15, 6, 27, 8, 19], 
       [23, 2, 54, 1, 4, ]] 
    
# mean of the flattened array 
print("\nmean of arr, axis = None : ", np.mean(arr)) 

mean of arr, axis = None :  18.6
  
# mean along the axis = 0 
print("\nmean of arr, axis = 0 : ", np.mean(arr, axis = 0)) 

mean of arr, axis = 0 :  [17.33333333  8.33333333 31.         14.         22.33333333]

# mean along the axis = 1 
print("\nmean of arr, axis = 1 : ", np.mean(arr, axis = 1))

mean of arr, axis = 1 :  [24.  15.  16.8]
Posted by: Guest on October-05-2021

Python Answers by Framework

Browse Popular Code Answers by Language