VOOZH about

URL: https://www.geeksforgeeks.org/python/calculate-the-mean-across-dimension-in-a-2d-numpy-array/

⇱ Calculate the mean across dimension in a 2D NumPy array - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Calculate the mean across dimension in a 2D NumPy array

Last Updated : 15 Jul, 2025

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

Example:

Output:

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
Comment