这里是代码将以团队名称
读取的输入csvimport csv
from datetime import datetime
with open('League.csv','r') as csvfile:
readCSV = csv.reader(csvfile,delimiter=',')
next(readCSV)
for row in readCSV:
#print(row)
lines = []
lines.append(row)
#print (lines)
teams = set ()
#print (teams)
for line in lines :
home_team = line[2]
teams.add(home_team)
#print (teams)
for team in teams:
match = [line for line in lines if line[2]==team]
#print(match)
for i in range(5, len(match)):
history = match [i-5:i]
average = (history / 5)
print(average)
这里是我想要读取的数字时间的代码,然后计算出平均值
game 1-5 Team one --- average
game 2-6 Team one --- average
game 3-7 Team one --- average
我想做的是在比赛中提到球队的每5次平均值。
期待输出
Public Function getArtikli() As DataTable
Dim query As String = "select id,named,group,art,vpc,mpc,currency,foot,pc from demo.artikli"
Dim table As New DataTable()
Using connection As New MySqlConnection(konekcija)
Using adapter As New MySqlDataAdapter(query, connection)
adapter.Fill(table)
Return table
End Using
End Using
End Function
谢谢。
答案 0 :(得分:0)
您正在使用4个嵌套for loops
,请将您的代码简化为一个 for loop
。
关于你的问题:
我想做的是在比赛中提到球队的每5次平均值。
问: ...每5次...... :请在您的问题中解释,5次看不到任何团队?
您想要 FT_goals 的平均值,每?
使用给定csv中的实际数据更新预期输出。