Want to calculate percentiles with Python/NumPy? We can calculate the percentiles with the following code. Copy the below python program and execute it to see the program output.
#Calculate percentiles with Python/ NumPy.
import numpy as np
a = np.array([1,2,3,4,5])
#Returns 50th percentile, e.g. median
p = np.percentile(a, 50)
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.