以下代码适用于每列的总和,但我想计算每个物种的平均值。
# Read data file into array
data = numpy.genfromtxt('data/iris.csv', delimiter=',')
# picking the first column of data
firstcol = data[:,0]
meanfirstcol = numpy.mean(data[:,0]) #defining meanfirstcol
print("Mean of First Column is:", meanfirstcol)
import pandas as pd; df = pd.read_csv( 'data/iris.csv', header=None, names=['花萼长度', '花萼宽度', '花瓣长度', '花瓣宽度', '种类'] )
- cs95