旅行好きなソフトエンジニアの備忘録

プログラミングや技術関連のメモを始めました

【Python】How to find the percentile scores of a numpy array? - 101 Numpy Exercises

Q:

irisデータの"sepallength"の5~95パーセンタイルを見つけなさい

A:

# Input
url = 'https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data'
sepallength = np.genfromtxt(url, delimiter=',', dtype='float', usecols=[0])

# Solution
np.percentile(sepallength, q=[5, 95])
#> array([ 4.6  ,  7.255])


www.machinelearningplus.com