FIFA Fun
A Fun Look at Player Data from FIFA 2019

Intro

I recently stumbled across a dataset that was especially interesting to me as a long time FIFA player. If you are not a FIFA enthusiast I hope you are not already switching off! I am certain that you can take something valuable and interesting from this small data exploration.

I will be using a Jupyter Notebook to explore the data and plotly for the plotting which I hope will embed nicely into this static website. ChartStudio is used to store all of the plots in the cloud and can be accessed easily within a notebook.

The Dataset

You can download the data set from Kaggle here.. I start by opening up a notebook and importing Numpy and Pandas as np and pd (what else would you do?). The data is provided as a CSV so I can read it in easily.

If I look at a summary of the data I see that I have 18,207 players with all of their FIFA stats plus some extra information like their Age, the country they represent and even some cool links to pictures of them and their flags.

The first thing I thought to look at was whether player prices correlate well with their overall rating.

Well that was kind of gross! We can see something is going on but if you look carefully the prices are all strings at pandas has no idea what to do with them. I’ll need to manipulate these strings to convert them to numbers which we can plot much more easily. Here is my approach:

strings = []
numbers = []

for number in df['Value']:
    number = str(number)
    if number == 'nan': #Handling the large number without a release clause
        strings.append('nan')
        numbers.append(0)
    elif number[-1:] == 'K':  # Check if the last digit is K
        strings.append(number[:-1] + " Thousand")  # Append a Thousand after removing the last char
        numbers.append(float(number[1:-1]) * 1000)  # Remove the last digit with [:-1], and convert to int and multiply by 1000
    elif number[-1:] == 'M':  # Check if the last digit is M
        strings.append(number[:-1] + " Million")  # Append a Million after removing the last char
        numbers.append(float(number[1:-1]) * 1000000)  # Remove the last digit with [:-1], and convert to int and multiply by 1000000
    else:  # just in case data doesnt have an M or K
        strings.append(number)
        numbers.append(int(number[1:]))

We can then add the numbers data back into the dataframe. Very easily:

data["Value_float"] = numbers

Now I’ll improve the plot by adding some extra features.

That’s a bit nicer! Now we can see the proper trend for price and I have split the colours intro general positions. We see how the maximum value and rating players are mostly forwards (clearly FIFA doesn’t appreciate the art of defence).

World Mapping

I decided to have a go using the inbuilt chloropleth functionaility within plotly. I decided to colour the countries by their average player rating and here are the results!

*****
James Petley
Contact at jwpetley@gmail.com
I hope you're having a great day!