|NO.Z.00035|——————————|BigDataEnd|——|Hadoop&Python.v13|——|Arithmetic.v13|NumPy科学计算库:NumPy分析鸢尾花花萼属性各项
一、实战-?NumPy分析鸢尾花花萼属性各项指标
Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm'd both hands before the fire of life.It sinks, and I am ready to depart ——W.S.Landor
### --- 案列:读取iris数据集中的花萼?度数据(已保存为csv格式)
~~~ 并对其进?排序、去重,并求出和、累积和、均值、标准差、?差、最?值、最?值。
import numpy as np # 导?类库 numpy
data = np.loadtxt('./iris.csv',delimiter = ',') # 读取数据?件,data是?维的数组
data.sort(axis = -1) # 简单排序
print('简单排序后:', data)
print('数据去重后:', np.unique(data)) # 去除重复数据
print('数据求和:', np.sum(data)) # 数组求和
print('元素求累加和', np.cumsum(data)) # 元素求累加和
print('数据的均值:', np.mean(data)) # 均值
print('数据的标准差:', np.std(data)) # 标准差
print('数据的?差:', np.var(data)) # ?差
print('数据的最?值:', np.min(data)) # 最?值
print('数据的最?值:', np.max(data)) # 最?值
Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm'd both hands before the fire of life.It sinks, and I am ready to depart ——W.S.Landor