Python Practice › NumPy Programs › Program 67
Median of each row
Write a NumPy program to find the median of each row.
Input
[[4, 8, 1], [2, 9, 6]]
Output
[4. 6.]
Approach
axis=1.
Solution
import numpy as npprint(np.median(np.array([[4, 8, 1], [2, 9, 6]]), axis=1))Output
[4. 6.]
Learn the concept
New to this topic? Read the lesson, then come back.