Numpy
Numpy (28)
Jun's N
2022. 8. 20. 21:55
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
728x90