分析谁是2020欧洲杯的最佳球员

2024-01-02 03:18

本文主要是介绍分析谁是2020欧洲杯的最佳球员,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

问题

欧洲杯刚刚结束,就像看看有没有欧洲杯的数,分析下谁是本次欧洲杯表现最好的球员。于是我就上网找了一组数据。

网盘地址(提取码:hc9s)

【1】文件结构

【2】数据空处理

import numpy as np 
import pandas as pd 
import warnings
warnings.filterwarnings("ignore")
import matplotlib.pyplot as plt
import seaborn as snsdf = pd.read_csv("./data/euro2020.csv")
print(df.head(10))summary = pd.DataFrame(df.dtypes, columns=["datatype"])
summary["isnull"] = df.isnull().sum() 
summary["unique"] = df.nunique()
summary["first"] = df.loc[0]
summary["second"] = df.loc[1]
summary["third"] = df.loc[2]
print(summary)print(len(df))
train_df = df.drop("Blocks", axis = 1)train_df = train_df.fillna(axis = 0, value = 0)print(train_df.columns)

输出数据列

Index(['Player', 'Country', 'Position', 'Match played', 'Goals','Right foot goals', 'Left foot goals', 'Header goals', 'Assists','Total attempts', 'On target', 'Off target', 'Woodwork', 'Shot blocks','Avg gpg', 'Fouls suffered', 'Fouls committed', 'Top speed','Passing accuracy', 'Distance covered', 'Clearence attempted','Balls recovered', 'Tackels', 'Yellow cards', 'Red cards','Minutes played'],dtype='object')

字段分析下

# Player :球员
# Country :国家
# Position :所处位置
# Match played :出场场次
# Goals :进球数
# Right foot goals :右脚进球数
# Left foot goals :左脚进球数
# Header goals :头球进球数
# Assists :助攻数
# Total attempts :总射门数
# On target :球门内
# Off target :球门外
# Woodwork :球门框上
# Shot blocks :拦截
# Avg gpg :场均得分
# Fouls suffered :被犯规数
# Fouls committed :犯规数
# Top speed :最高速度
# Passing accuracy :传球准确度
# Distance covered :奔跑距离
# Balls recovered :抢断
# Tackles :铲球
# Yellow cards :黄牌数
# Red cards :红牌数
# Minutes played :上场时长

【3】整体数据集分布

fig, ax = plt.subplots(13,2, figsize=(100,300))
for idx, col in enumerate(train_df.columns.to_list()):row_idx = idx//2col_idx = idx%2sns.countplot(data=train_df, x = col,  color = "red", ax = ax[row_idx, col_idx])
plt.show()

【4】处理自己需要的数据

top_players = train_df.sort_values(["Goals"], ascending=False).iloc[:10]
train_df["gpa"] = train_df["Goals"]/train_df["Total attempts"]
attempts = train_df.sort_values(["gpa"], ascending=False).iloc[:10]
agp = train_df.sort_values(["Avg gpg"], ascending=False).iloc[:10]
passing_accuracy = train_df.sort_values(["Passing accuracy"], ascending=False).iloc[:10]
header = train_df.sort_values(["Header goals"], ascending=False).iloc[:10]

 【5】总进球数

# 进球数排名top10
plt.figure(figsize=(20,5))
sns.barplot(x = "Player", data = top_players, y = "Goals", palette = "Greys", hue = "Position")
plt.title("Top players on the basis of max goals")
plt.show()

# 场均进球排名top10
fig, ax = plt.subplots(2, 1,figsize=(20,10))
sns.barplot(x = "Player", data = agp, y = "Avg gpg", palette = "Greys", ax = ax[0])
sns.barplot(x = "Country", data = agp, y = "Avg gpg", palette = "Greens", ax = ax[1])
plt.show()

这个就奇怪了,直观的感受好像,意大利对获得了冠军,为啥场均进球数这么少。。意大利的比赛是多难看。。

然后其他数据就当做参考吧。

【6】其他

# 传球
plt.figure(figsize=(20,5))
sns.barplot(x = "Player", data = passing_accuracy, y = "Passing accuracy", palette = "Blues")
plt.title("Top players on the basis of passing accuracy")
plt.show()# 头球
plt.figure(figsize=(20,5))
sns.barplot(x = "Player", data = header, y = "Header goals", palette = "Reds", hue = "Goals")
plt.title("Top players on the basis header goals")
plt.show()# 速度
speedy = train_df.sort_values(["Top speed"], ascending=False).iloc[:10]
plt.figure(figsize=(20,5))
sns.barplot(x = "Player", data = speedy, y = "Top speed", palette = "Greens")
plt.title("Top playerson the basis of their speed")
plt.show()# 黄牌数
yelloww = train_df.sort_values(["Yellow cards"], ascending=False).iloc[:10]
plt.figure(figsize=(20,5))
sns.barplot(x = "Player", data = yelloww, y = "Yellow cards", palette = "Greens")
plt.title("Yellow card receivers")
plt.show()# 抢断
blockers = train_df.sort_values(["Shot blocks"], ascending=False).iloc[:10]
plt.figure(figsize=(20,5))
sns.barplot(x = "Player", data = blockers, y = "Shot blocks", palette = "Blues")
plt.title("Shot Blockers")
plt.show()# 出场场次
blockers = train_df.sort_values(["Match played"], ascending=False).iloc[:10]
plt.figure(figsize=(20,5))
sns.barplot(x = "Player", data = blockers, y = "Match played", palette = "Oranges")
plt.title("Matches Played")
plt.show()# 助攻
Assisters = train_df.sort_values(["Assists"], ascending=False).iloc[:10]
plt.figure(figsize=(20,5))
sns.barplot(x = "Player", data = Assisters, y = "Assists", palette = "Greens")
plt.title("Matches Played")
plt.show()# 传球不好的
Worst_passers = train_df.sort_values(["Passing accuracy"], ascending=True).iloc[:10]
plt.figure(figsize=(20,5))
sns.barplot(x = "Player", data = Worst_passers, y = "Passing accuracy", palette = "Greens")
plt.title("Not good Passers")
plt.show()# 被犯规数
Foulers = train_df.sort_values(["Fouls suffered"], ascending=False).iloc[:10]
plt.figure(figsize=(20,5))
sns.barplot(x = "Player", data = Foulers, y = "Fouls suffered", palette = "Greens")
plt.title("Foul sufferers")
plt.show()# 犯规数
Foulers = train_df.sort_values(["Fouls committed"], ascending=False).iloc[:10]
plt.figure(figsize=(20,5))
sns.barplot(x = "Player", data = Foulers, y = "Fouls committed", palette = "Greens")
plt.title("Foul makers")
plt.show()

【7】总结

最后去看了下,最后欧洲杯的最佳球员是谁,有点意料之外的,尽然是意大利的守门员。。如果是这样。守门员的数据需要单独拿出来比较。这样也说明了,意大利对真的是看守门员的。。哈哈

这篇关于分析谁是2020欧洲杯的最佳球员的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/561205

相关文章

Java调用DeepSeek API的最佳实践及详细代码示例

《Java调用DeepSeekAPI的最佳实践及详细代码示例》:本文主要介绍如何使用Java调用DeepSeekAPI,包括获取API密钥、添加HTTP客户端依赖、创建HTTP请求、处理响应、... 目录1. 获取API密钥2. 添加HTTP客户端依赖3. 创建HTTP请求4. 处理响应5. 错误处理6.

Springboot中分析SQL性能的两种方式详解

《Springboot中分析SQL性能的两种方式详解》文章介绍了SQL性能分析的两种方式:MyBatis-Plus性能分析插件和p6spy框架,MyBatis-Plus插件配置简单,适用于开发和测试环... 目录SQL性能分析的两种方式:功能介绍实现方式:实现步骤:SQL性能分析的两种方式:功能介绍记录

最长公共子序列问题的深度分析与Java实现方式

《最长公共子序列问题的深度分析与Java实现方式》本文详细介绍了最长公共子序列(LCS)问题,包括其概念、暴力解法、动态规划解法,并提供了Java代码实现,暴力解法虽然简单,但在大数据处理中效率较低,... 目录最长公共子序列问题概述问题理解与示例分析暴力解法思路与示例代码动态规划解法DP 表的构建与意义动

C#使用DeepSeek API实现自然语言处理,文本分类和情感分析

《C#使用DeepSeekAPI实现自然语言处理,文本分类和情感分析》在C#中使用DeepSeekAPI可以实现多种功能,例如自然语言处理、文本分类、情感分析等,本文主要为大家介绍了具体实现步骤,... 目录准备工作文本生成文本分类问答系统代码生成翻译功能文本摘要文本校对图像描述生成总结在C#中使用Deep

SpringBoot项目中Maven剔除无用Jar引用的最佳实践

《SpringBoot项目中Maven剔除无用Jar引用的最佳实践》在SpringBoot项目开发中,Maven是最常用的构建工具之一,通过Maven,我们可以轻松地管理项目所需的依赖,而,... 目录1、引言2、Maven 依赖管理的基础概念2.1 什么是 Maven 依赖2.2 Maven 的依赖传递机

Java内存泄漏问题的排查、优化与最佳实践

《Java内存泄漏问题的排查、优化与最佳实践》在Java开发中,内存泄漏是一个常见且令人头疼的问题,内存泄漏指的是程序在运行过程中,已经不再使用的对象没有被及时释放,从而导致内存占用不断增加,最终... 目录引言1. 什么是内存泄漏?常见的内存泄漏情况2. 如何排查 Java 中的内存泄漏?2.1 使用 J

Redis主从/哨兵机制原理分析

《Redis主从/哨兵机制原理分析》本文介绍了Redis的主从复制和哨兵机制,主从复制实现了数据的热备份和负载均衡,而哨兵机制可以监控Redis集群,实现自动故障转移,哨兵机制通过监控、下线、选举和故... 目录一、主从复制1.1 什么是主从复制1.2 主从复制的作用1.3 主从复制原理1.3.1 全量复制

Redis主从复制的原理分析

《Redis主从复制的原理分析》Redis主从复制通过将数据镜像到多个从节点,实现高可用性和扩展性,主从复制包括初次全量同步和增量同步两个阶段,为优化复制性能,可以采用AOF持久化、调整复制超时时间、... 目录Redis主从复制的原理主从复制概述配置主从复制数据同步过程复制一致性与延迟故障转移机制监控与维

Redis连接失败:客户端IP不在白名单中的问题分析与解决方案

《Redis连接失败:客户端IP不在白名单中的问题分析与解决方案》在现代分布式系统中,Redis作为一种高性能的内存数据库,被广泛应用于缓存、消息队列、会话存储等场景,然而,在实际使用过程中,我们可能... 目录一、问题背景二、错误分析1. 错误信息解读2. 根本原因三、解决方案1. 将客户端IP添加到Re

Redis主从复制实现原理分析

《Redis主从复制实现原理分析》Redis主从复制通过Sync和CommandPropagate阶段实现数据同步,2.8版本后引入Psync指令,根据复制偏移量进行全量或部分同步,优化了数据传输效率... 目录Redis主DodMIK从复制实现原理实现原理Psync: 2.8版本后总结Redis主从复制实