9951 explained code solutions for 126 technologies


python-numpyHow to calculate percentile from Numpy array


import numpy as np
arr = np.array([1,2,3,6,7,8,10,11,12,15,16,17])

p10 = np.percentile(arr, 10)
p50 = np.percentile(arr, 50)
p95 = np.percentile(arr, 95)ctrl + c
import numpy as np

load Numpy module for Python

np.array

declare Numpy array

np.percentile

calculate percentile of a given array on a given level

p10

10% percentile

p50

50% percentile (same as average)

p95

95% percentile