The project aim is to see how many goals are in the tournament, how many fouls are in this tournament and also see how many assists are done in this tournament using machine learning in Python.
Step: 1
First, we upload the necessary libraries and then we upload the dataset
import numpy as np import pandas as pd import seaborn as sns import matplotlib.pyplot as plt
Euro_Cup = pd.read_csv("EURO_CUP_2020.csv") Euro_Cup
Euro_Cup.columns
Euro_Cup.describe()
Step: 2
Now we see the position
plt.figure(figsize=(9,7)) Euro_Cup.Position.value_counts().plot(kind='pie', autopct='%.2f',colors=['tomato', 'gold', 'skyblue']) plt.show()
Here we see midfielders have a 41.38% position in this tournament
plt.figure(figsize=(12,10)) Euro_Cup['Avg gpg'].value_counts().plot(kind='pie',autopct='%.2f') plt.show()
plt.figure(figsize=(12,6)) plt.subplot(1,2,1) sns.boxplot(x='On target',data=Euro_Cup) plt.subplot(1,2,2) sns.boxplot(x='Off target',data=Euro_Cup) plt.show()
Here we see how many goals are in on the target and off target
Step: 3
Now we see the total goal by a player
EURO = Euro_Cup[Euro_Cup['Goals']>0] #Plotting a barplot plt.figure(figsize=(20,15)) plt.title('Total goals by players', fontsize=20) sns.barplot(x='Player',y='Goals',data=EURO, order=EURO.sort_values('Goals',ascending = False).Player) plt.xticks(rotation = 90) plt.show()
here we see the Cristiano Ronaldo is the top goal scorer
plt.figure(figsize=(15,8)) plt.title('Total goals by Countries', fontsize=20) sns.barplot(x='Country',y='Goals',data=EURO ,estimator=sum, ci=None) plt.xticks(rotation = 90) plt.show()
plt.figure(figsize=(14,6)) sns.set_theme(style="whitegrid") plt.subplot(1,2,1) plt.title("Right foot goals", fontsize=20) sns.barplot(x='Right foot goals',y='Goals',data=Euro_Cup ,estimator=sum, ci=None) plt.subplot(1,2,2) plt.title("Left foot goals", fontsize=20) sns.barplot(x='Left foot goals',y='Goals',data=Euro_Cup ,estimator=sum, ci=None) plt.show()
here we see how many goals from right foot and left foot
Euro_Cup_Assists = Euro_Cup[Euro_Cup['Assists']>0] plt.figure(figsize=(10,8)) sns.set_theme(style="whitegrid") plt.title('Total Assists by players', fontsize=20) sns.barplot(x='Player',y='Assists',data=Euro_Cup_Assists ,estimator=sum, ci=None,order=Euro_Cup_Assists.sort_values(by=['Assists'], ascending=False).Player) plt.xticks(rotation = 90) plt.show()
Total assists by Players
Step: 4
plt.figure(figsize=(10,6)) sns.set_theme(style="whitegrid") sns.barplot(x='Country',y='Yellow cards',data=Euro_Cup,estimator=sum, ci=None) plt.xticks(rotation = 90) plt.show()
here we see Italy have the most number of yellow cards
plt.figure(figsize=(16,8)) plt.title('Total Fouls committed by players', fontsize=20) sns.barplot(x='Player',y='Fouls committed',data=Euro_Cup,estimator=sum, ci=None,order=Euro_Cup.sort_values(by=['Fouls committed'], ascending=False).Player) plt.xticks(rotation = 90) plt.show()
Here we see the total number of fouls committed by players
Submitted by Subhojit Jalal (Subhojit1234)
Download packets of source code on Coders Packet
Comments