How to find median in Python using NumPy

You can find the median in Python using NumPy with the following code. If you want to learn Python then I will highly recommend you to read This Book.

How to find median in Python using NumPy
How to find median in Python using NumPy

Median of Odd Set

import numpy as np
a = [1,2,3,4,5]
print(np.median(a))
#output 3.0

Median of Even Set

import numpy as np
b = [1,2,2,4,5,6]
print(np.median(b))
#output 3.0

Median of Two Numbers

import numpy as np
c = [1,2]
print(np.median(c))
#output 1.5

Median of not arranged Numbers

import numpy as np
a = [6,1,2,3,4,5]
print(np.median(a))
#output 3.5

People are also reading:

Best Python Books

What is Computer Vision? Examples, Applications, Techniques

Top 10 Computer Vision Books with Python

Books for Machine Learning (ML)

Free Learning Resources

Leave a Comment

Your email address will not be published.