{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": true }, "outputs": [], "source": [ "import pandas as pd\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "%matplotlib inline\n", "import seaborn as sns\n", "sns.set(font_scale=2)\n", "sns.set_style(\"whitegrid\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Principal Components of FIFA Dataset\n", "Like the last class activity, we will be using the data analysis library `pandas`. This time we will be looking at the [FIFA 2018 Dataset](https://www.kaggle.com/thec03u5/fifa-18-demo-player-dataset/kernels). While this is a video game, the developers strive to make their game as accurate as possible, so this data reflects the skills of the real-life players.\n", "\n", "Let's load the data frame using `pandas`." ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": true }, "outputs": [], "source": [ "df = pd.read_csv(\"FIFA_2018.csv\",encoding = \"ISO-8859-1\",index_col = 0, low_memory = False)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can take a brief look at the data by calling `df.head()`. The first 34 columns are attributes that describe the behavior (e.g. aggression) or the skills (e.g. ball control), of each player. The final columns show the player's position, name, nationality, and the club they play for.\n", "\n", "The four positions are forward (FWD), midfielder (MID), defender (DEF), and goalkeeper (GK)." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | Acceleration | \n", "Aggression | \n", "Agility | \n", "Balance | \n", "Ball control | \n", "Composure | \n", "Crossing | \n", "Curve | \n", "Dribbling | \n", "Finishing | \n", "... | \n", "Sprint speed | \n", "Stamina | \n", "Standing tackle | \n", "Strength | \n", "Vision | \n", "Volleys | \n", "Position | \n", "Name | \n", "Nationality | \n", "Club | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | \n", "89 | \n", "63 | \n", "89 | \n", "63 | \n", "93 | \n", "95 | \n", "85 | \n", "81 | \n", "91 | \n", "94 | \n", "... | \n", "91 | \n", "92 | \n", "31 | \n", "80 | \n", "85 | \n", "88 | \n", "FWD | \n", "Cristiano Ronaldo | \n", "Portugal | \n", "Real Madrid CF | \n", "
1 | \n", "92 | \n", "48 | \n", "90 | \n", "95 | \n", "95 | \n", "96 | \n", "77 | \n", "89 | \n", "97 | \n", "95 | \n", "... | \n", "87 | \n", "73 | \n", "28 | \n", "59 | \n", "90 | \n", "85 | \n", "FWD | \n", "L. Messi | \n", "Argentina | \n", "FC Barcelona | \n", "
2 | \n", "94 | \n", "56 | \n", "96 | \n", "82 | \n", "95 | \n", "92 | \n", "75 | \n", "81 | \n", "96 | \n", "89 | \n", "... | \n", "90 | \n", "78 | \n", "24 | \n", "53 | \n", "80 | \n", "83 | \n", "FWD | \n", "Neymar | \n", "Brazil | \n", "Paris Saint-Germain | \n", "
3 | \n", "88 | \n", "78 | \n", "86 | \n", "60 | \n", "91 | \n", "83 | \n", "77 | \n", "86 | \n", "86 | \n", "94 | \n", "... | \n", "77 | \n", "89 | \n", "45 | \n", "80 | \n", "84 | \n", "88 | \n", "FWD | \n", "L. Su\u0090\u008drez | \n", "Uruguay | \n", "FC Barcelona | \n", "
4 | \n", "58 | \n", "29 | \n", "52 | \n", "35 | \n", "48 | \n", "70 | \n", "15 | \n", "14 | \n", "30 | \n", "13 | \n", "... | \n", "61 | \n", "44 | \n", "10 | \n", "83 | \n", "70 | \n", "11 | \n", "GK | \n", "M. Neuer | \n", "Germany | \n", "FC Bayern Munich | \n", "
5 rows \u00d7 38 columns
\n", "