Calculate the mean across dimension in a 2D NumPy array
We can find out the mean of each row and column of 2d array using numpy with the function np.mean(). Here we have to provide the axis for finding mean.
Syntax: numpy.mean(arr, axis = None)
For Row mean: axis=1
For Column mean: axis=0
Mean of Row 1 is 2.0 Mean of Row 2 is 5.0 Mean of Row 3 is 8.0 Mean of column 1 is 4.0 Mean of column 2 is 5.0 Mean of column 3 is 6.0
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course