Median of the matrix along the column using NumPy

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

Output :

				
					Median of array along column: [4.  5.5]
				
			

find the median of the matrix along the rows.

make an array immutable i.e. read-only.

Leave a Comment