# credit to the source link import numpy as np quant = np.quantile(arr, q) # arr: array - like object (list or np.array) # q: float from 0 to 1