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