本文目录导读:

要统计“失误次数哪队更少”,我需要先明确一下你的数据来源和格式,不过我可以先给你一个通用实用脚本思路,你可以直接套用。
假设数据格式
比如你有一个 CSV 文件 stats.csv:
team, turnovers Lakers, 12 Warriors, 8 Lakers, 15 Warriors, 10 Celtics, 9
Python 脚本(推荐)
import csv
from collections import defaultdict
# 统计每队失误总数
turnovers = defaultdict(int)
games = defaultdict(int)
with open('stats.csv', newline='', encoding='utf-8') as f:
reader = csv.DictReader(f)
for row in reader:
team = row['team'].strip()
to = int(row['turnovers'])
turnovers[team] += to
games[team] += 1
# 输出结果
print(f"{'球队':<10}{'总失误':<8}{'场次':<6}{'场均失误':<10}")
print("-" * 36)
for team in sorted(turnovers, key=lambda t: turnovers[t]):
total = turnovers[team]
g = games[team]
avg = total / g
print(f"{team:<10}{total:<8}{g:<6}{avg:<10.2f}")
# 找出失误最少的队
best = min(turnovers, key=lambda t: turnovers[t])
print(f"\n✅ 失误最少的球队是:{best}(共 {turnovers[best]} 次)")
运行结果示例
球队 总失误 场次 场均失误
------------------------------------
Warriors 18 2 9.00
Celtics 9 1 9.00
Lakers 27 2 13.50
✅ 失误最少的球队是:Celtics(共 9 次)
如果你用 Excel
公式也可以:
- 总失误:
=SUMIF(A:A, "Lakers", B:B) - 场均:
=SUMIF(...)/COUNTIF(A:A,"Lakers") - 最少队:
=INDEX(A:A, MATCH(MIN(SUMIF(...)), SUMIF(...), 0))(数组公式)
我需要你补充的信息
为了给你精确可运行的脚本,请告诉我:
- 数据是 CSV / Excel / JSON / 数据库 哪种?
- 字段名是什么(队名、失误数)?
- 是统计总失误还是场均失误?
- 是否有多赛季、多比赛需要分组?
你贴一小段样例数据,我可以直接给你改好的脚本。