查找值的在該領域[定量]平均大於或等於(337) 這是定量字段需要幫助上平均的Python
quant
100
7
109
204
28
292
105
254
441
401
410
14
15
51
96
403
75
31
109
17
這是我試圖
代碼import csv
total = count = 0
with open('3111111a.csv', newline='') as f:
reader = csv.reader(f)
next(reader, None)
for row in reader:
total += float(row[4])
count += 1
if count:
average = total/count
print('The average of the values is {}'.format(average))
你不應該只是平均數值大於或等於337? – LittleBobbyTables 2013-05-13 13:04:58
對不起...我是一個初學者..我正在努力與此。是的,我應該,但我的代碼是錯誤的...我想 – Jake 2013-05-13 13:08:13
sum([x for x in l if x> = 337])/ len(l)其中l是你定量列表 – Denis 2013-05-13 13:11:48