Python Practice › NumPy Programs › Program 68

Median of each column

EasyNumPy Programs · 68 of 100

Write a NumPy program to find the median of each column.

Advertisement
Input
[[4, 8, 1], [2, 9, 6]]
Output
[3.  8.5 3.5]

Approach

  1. axis=0.

Solution

Python
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.

More numpy programs

← All 100 NumPy Programs

Leave a Comment