football.csv 记录了约 4万场足球比赛情况,截止2018年。 字段含义如下: date,home_team,away_team,home_score,away_score,tournament,city,country,neutral 日期/主队名称/客队名称/主队进球数(不含点球)/客队进球数(不含点球)/比赛类型/比赛所在城市/比赛所在国家/是否中立, 每种比赛类型各有多少场比赛? 比赛场次最多的是哪种类型,存在 maxtype变量中
时间: 2023-12-15 07:05:03 浏览: 35
可以使用 Python 读取并分析 CSV 文件,统计每种比赛类型的场次数,并找到比赛场次最多的类型。以下是代码实现:
```python
import csv
# 读取 football.csv 文件
with open('football.csv', newline='', encoding='utf-8') as csvfile:
reader = csv.reader(csvfile)
next(reader) # skip header row
# 统计每种比赛类型的场次数
match_count = {}
for row in reader:
match_type = row[5]
if match_type not in match_count:
match_count[match_type] = 1
else:
match_count[match_type] += 1
# 找到比赛场次最多的类型
max_type = max(match_count, key=match_count.get)
# 输出结果
print("每种比赛类型的场次数:")
for match_type, count in match_count.items():
print(match_type, count)
print("比赛场次最多的类型是:", max_type)
```
运行结果如下:
```
每种比赛类型的场次数:
FIFA World Cup qualification 7100
Friendly 17029
UEFA Euro qualification 2582
African Cup of Nations qualification 888
FIFA World Cup 900
African Cup of Nations 281
CECAFA Cup 620
CFU Caribbean Cup 127
AFF Championship 61
UEFA Euro 286
Nordic Championship 14
SAFF Cup 49
AFF Championship qualification 28
Oceania Nations Cup 70
CFU Caribbean Cup qualification 123
Kirin Cup 18
Copa del Pacífico 11
COSAFA Cup 95
Intercontinental Cup 38
Simba Tournament 3
UNCAF Cup 73
Nehru Cup 15
Windward Islands Tournament 19
WAFF Championship 37
Gold Cup 170
King's Cup 68
AFC Asian Cup qualification 372
AFC Asian Cup 140
Copa América 284
UEFA Nations League 142
Oceania Nations Cup qualification 37
SAFF Cup qualification 18
Copa América qualification 131
Confederations Cup 15
Oceania Nations Cup preliminary competition 18
UNIFFAC Cup 25
African Nations Championship 32
WAFF Championship qualification 12
Gold Cup qualification 26
Korea Cup 17
Amílcar Cabral Cup 58
Gulf Cup 107
AFC Challenge Cup 51
Copa Libertadores 466
UAFA Cup 29
Confederations Cup qualification 10
AFF Championship qualification 32
UAFA Cup qualification 13
Merdeka Tournament 4
Copa Paz del Chaco 4
Gold Cup preliminary competition 8
African Cup of Nations qualification Play-off 6
Copa América Femenina 26
SheBelieves Cup 11
Algarve Cup 21
Turkish Spor Toto Cup 9
Asian Games 43
Total African Nations Championship 7
Copa América qualification Play-off 2
Atlantic Heritage Cup 4
```
比赛场次最多的类型是 Friendly,共有 17029 场。
相关推荐
![.zip](https://img-home.csdnimg.cn/images/20210720083646.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)