Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import numpy as np
a1=np.array([[2,4,6],[8,9,10],[12,14,16]])
#Calcualting mean
print (np.mean(a1))
#Output:9.0
#Calculating mean for each row
print (np.mean(a1,axis=1))
#Output:[ 4. 9. 14.]
#Calculating mean for each column
print (np.mean(a1,axis=0))
#Output:[ 7.33333333 9. 10.66666667]
print (np.median(a1))
#Output:9.0
print (np.sum(a1))
#Output:81
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment