In this python numpy program, we will find the median of the matrix along the rows using NumPy.
Steps to solve the program
- Import the numpy library as np.
- Create an array using np.array().
- Find the median of the matrix along the rows using np.median() and set the axis equal to 0.
- 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]