Median of the matrix along the rows using NumPy

In this python numpy program, we will find the median of the matrix along the rows using NumPy.

Steps to solve the program
  1. Import the numpy library as np.
  2. Create an array using np.array().
  3. Find the median of the matrix along the rows using np.median() and set the axis equal to 0.
  4. Print the output.
				
					import numpy as np
x = np.array([[5, 3],[7, 4]])
print("Median of array along row:",np.median(x,axis=0))
				
			

Output :

				
					Median of array along row: [6.  3.5]
				
			

find the median of the matrix.

find the median of the matrix along the column.

Leave a Comment