Note

Numpy (28) 본문

Numpy

Numpy (28)

알 수 없는 사용자 2022. 8. 20. 21:55
728x90

How to compute the mean, median, standard deviation of a numpy array?

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

# Solution
mu, med, sd = np.mean(sepallength), np.median(sepallength), np.std(sepallength)
print(mu, med, sd)

# output
5.84333333333 5.8 0.825301291785

'Numpy' 카테고리의 다른 글

Numpy (30)  (0) 2022.08.22
Numpy (29)  (0) 2022.08.21
Numpy (27)  (0) 2022.08.19
Numpy (26)  (0) 2022.08.17
Numpy (25)  (0) 2022.08.16
Comments