Find the median of the matrix using NumPy.

In this python numpy program, we will find the median of the matrix 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 using np.median().
  4. Print the output.
				
					import numpy as np
x = np.array([[5, 3],[7, 4]])
print("Median of array:",np.median(x))
				
			

Output :

				
					Median of array: 4.5
				
			

get the number of nonzero elements in an array.

find the median of the matrix along the rows.

Leave a Comment