FIFA19 is the official football game of EA Sports. Queries in the following project are based on the Player Dataset of FIFA19. This Dataset is available in Kaggle which is a hub of datasets. This dataset consists of details of players and their stats in the year 2019. This can be used to determine success ratio, ratings, top players etc.
In this project I have used Numpy, Pandas, Matplotlib and Seaborn. This project is part of the course Data Analysis with Python: Zero to Pandas.
This is an executable Jupyter notebook hosted on Jovian.ml, a platform for sharing data science projects. You can run and experiment with the code in a couple of ways: using free online resources (recommended) or on your own computer.
The easiest way to start executing this notebook is to click the "Run" button at the top of this page, and select "Run on Binder". This will run the notebook on mybinder.org, a free online service for running Jupyter notebooks. You can also select "Run on Colab" or "Run on Kaggle".
Install Conda by following these instructions. Add Conda binaries to your system
PATH, so you can use the
conda command on your terminal.
Create a Conda environment and install the required libraries by running these commands on the terminal:
conda create -n zerotopandas -y python=3.8 conda activate zerotopandas pip install jovian jupyter numpy pandas matplotlib seaborn opendatasets --upgrade
jovian clone notebook-owner/notebook-id
cd directory-nameand start the Jupyter notebook.
You can now access Jupyter's web interface by clicking the link that shows up on the terminal or by visiting http://localhost:8888 on your browser. Click on the notebook file (it has a
.ipynb extension) to open it.
Datasets can be downloaded within Jupyter using the opendatasets Python Library.
!pip install jovian opendatasets --upgrade --quiet
Let's begin by downloading the data, and listing the files within the dataset.
dataset_url = 'https://www.kaggle.com/karangadiya/fifa19'
import opendatasets as od od.download(dataset_url)
Please provide your Kaggle credentials to download this dataset. Learn more: http://bit.ly/kaggle-creds Your Kaggle username: gauravbisht005 Your Kaggle Key: ········
100%|██████████| 2.18M/2.18M [00:00<00:00, 103MB/s]
Downloading fifa19.zip to ./fifa19
The dataset has been downloaded and extracted.
data_dir = './fifa19'
import os os.listdir(data_dir)
Let us save and upload our work to Jovian before continuing.
project_name = "FIFA19-Player-Data-Analysis"
!pip install jovian --upgrade -q
[jovian] Attempting to save notebook.. [jovian] Please enter your API key ( from https://jovian.ml/ ): API KEY: ········ [jovian] Updating notebook "gauravbisht005/fifa19-player-data-analysis" on https://jovian.ml/ [jovian] Uploading notebook.. [jovian] Capturing environment.. [jovian] Committed successfully! https://jovian.ml/gauravbisht005/fifa19-player-data-analysis
Data Cleaning is the process of finding and correcting inaccurate or incomplete records in dataset by replacing/ modifying/ removing those records so that the dataset is prepared to be operated.
import pandas as pd
fifa19_df = pd.read_csv(data_dir + "/data.csv")
Index(['Unnamed: 0', 'ID', 'Name', 'Age', 'Photo', 'Nationality', 'Flag', 'Overall', 'Potential', 'Club', 'Club Logo', 'Value', 'Wage', 'Special', 'Preferred Foot', 'International Reputation', 'Weak Foot', 'Skill Moves', 'Work Rate', 'Body Type', 'Real Face', 'Position', 'Jersey Number', 'Joined', 'Loaned From', 'Contract Valid Until', 'Height', 'Weight', 'LS', 'ST', 'RS', 'LW', 'LF', 'CF', 'RF', 'RW', 'LAM', 'CAM', 'RAM', 'LM', 'LCM', 'CM', 'RCM', 'RM', 'LWB', 'LDM', 'CDM', 'RDM', 'RWB', 'LB', 'LCB', 'CB', 'RCB', 'RB', 'Crossing', 'Finishing', 'HeadingAccuracy', 'ShortPassing', 'Volleys', 'Dribbling', 'Curve', 'FKAccuracy', 'LongPassing', 'BallControl', 'Acceleration', 'SprintSpeed', 'Agility', 'Reactions', 'Balance', 'ShotPower', 'Jumping', 'Stamina', 'Strength', 'LongShots', 'Aggression', 'Interceptions', 'Positioning', 'Vision', 'Penalties', 'Composure', 'Marking', 'StandingTackle', 'SlidingTackle', 'GKDiving', 'GKHandling', 'GKKicking', 'GKPositioning', 'GKReflexes', 'Release Clause'], dtype='object')
missing_data = pd.isna(fifa19_df.columns).sum() missing_data
Fortunately, there was no missing data in the dataset!!
fifa19_df.drop("Unnamed: 0",axis=1, inplace= True) fifa19_df
There was no missing data in the dataset but an unnecessary attribute which has been removed above.
[jovian] Attempting to save notebook.. [jovian] Updating notebook "gauravbisht005/fifa19-player-data-analysis" on https://jovian.ml/ [jovian] Uploading notebook.. [jovian] Capturing environment.. [jovian] Committed successfully! https://jovian.ml/gauravbisht005/fifa19-player-data-analysis
In the following segment, I have analysed datasets to summarise general main characterstics using visual methods with the help of Python Libraries such as Matplotlib.pyplot and Seaborn.
Let's begin by importing
import seaborn as sns import matplotlib import matplotlib.pyplot as plt %matplotlib inline sns.set_style('darkgrid') matplotlib.rcParams['font.size'] = 14 matplotlib.rcParams['figure.figsize'] = (9, 5) matplotlib.rcParams['figure.facecolor'] = '#00000000'
plt.figure(figsize = (25, 25)) sns.heatmap(fifa19_df.corr(), annot = True, fmt = '.1f') plt.title("Corelation between the properties of attributes of football players") plt.show()