How do I count the percentiles with python/numpy?

637    Asked by BernadetteBond in Python , Asked on Feb 19, 2021
Answered by Bernadette Bond

To calculate percentile with python you might be interested in the SciPy Stats package. It has the percentile function you're after and many other statistical goodies.

percentile() is available in numpy too.

import numpy as np

a = np.array([1,2,3,4,5])

p = np.percentile(a, 50)

print p

3.0



Your Answer

Interviews

Parent Categories