Football

In this exaample, we use the 'football' dataset to predict the outcomes of games between various teams. You can download the Jupyter Notebook of the study here.

  • date: Date of the game
  • home_team: Home Team
  • home_score: Home Team number of goals
  • away_team: Away Team
  • away_score: Away Team number of goals
  • tournament: Game Type (World Cup, Friendly...)
  • city: City where the game took place
  • country: Country where the game took place
  • neutral: If the event took place to a neutral location

We will follow the data science cycle (Data Exploration - Data Preparation - Data Modeling - Model Evaluation - Model Deployment) to solve this problem.

Initialization

This example uses the following version of VerticaPy:

In [1]:
import verticapy as vp
vp.__version__
Out[1]:
'0.9.0'

Connect to Vertica. This example uses an existing connection called "VerticaDSN." For details on how to create a connection, use see the connection tutorial.

In [2]:
vp.connect("VerticaDSN")

Let's create a Virtual DataFrame of the dataset. The dataset is available here.

In [9]:
football = vp.read_csv("data/football.csv")
football.head(5)
Out[9]:
📅
date
Date
Abc
home_team
Varchar(64)
Abc
away_team
Varchar(64)
123
home_score
Int
123
away_score
Int
Abc
tournament
Varchar(84)
Abc
city
Varchar(56)
Abc
country
Varchar(64)
010
neutral
Boolean
11872-11-30ScotlandEngland00FriendlyGlasgowScotland
21873-03-08EnglandScotland42FriendlyLondonEngland
31874-03-07ScotlandEngland21FriendlyGlasgowScotland
41875-03-06EnglandScotland22FriendlyLondonEngland
51876-03-04ScotlandEngland30FriendlyGlasgowScotland
Rows: 1-5 | Columns: 9

Data Exploration

Let's explore the data by displaying descriptive statistics of all the columns.

In [4]:
football["date"].describe()
Out[4]:
value
name"date"
dtypedate
count41586
min1872-11-30
max2020-02-01
Rows: 1-5 | Columns: 2

The dataset includes a total of 41,586 games, which take place between 1872 and 2020. Let's look at our game types and teams.

In [5]:
football["tournament"].describe()
Out[5]:
value
"tournament"
varchar(84)
112.0
41586.0
17029
10630
7236
2582
1672
900
813
Rows: 1-11 | Columns: 2

Different types of tournaments took place (FIFA World Cup, UEFA Euro, etc.) aand most of the games in our data are friendlies or qualifiers for international tournaments.

In [6]:
display(football.describe())
football.describe(method = "categorical")
count
mean
std
min
approx_25%
approx_50%
approx_75%
max
"home_score"415861.745755783196281.753780340476990.01.01.02.031.0
"away_score"415861.187587168758721.405323468335890.00.01.02.021.0
"neutral"415860.2472466695522520.4314165382756490.00.00.00.01.0
Rows: 1-3 | Columns: 9
Out[6]:
dtype
count
top
top_percent
"date"date415862012-02-290.159
"home_team"varchar(64)41586Brazil1.366
"away_team"varchar(64)41586Uruguay1.301
"home_score"int41586129.57
"away_score"int41586037.135
"tournament"varchar(84)41586Friendly40.949
"city"varchar(56)41586Kuala Lumpur1.416
"country"varchar(64)41586United States2.787
"neutral"boolean41586
75.275
Rows: 1-9 | Columns: 5

The dataset includes 308 national teams. For most of the games, the home team scores better than the away team. Since some games take place in a neutral location, we can ensure this hypothesis using the variable 'neutral.' Notice also that the number of goals per match is pretty low (median of 1 for both away and home teams).

Goal

Our goal for the study will be to predict the outcomes of games after 2015.

Before doing the study, we can notice that some teams names have changed over time. We need to change the old names by the new names otherwise it will add too much bias in the data.

In [10]:
for team in ["home_team", "away_team"]:
    football[team].decode('German DR', 'Germany',
                          'Czechoslovakia', 'Czech Republic',
                          'Yugoslavia', 'Serbia',
                          'Yemen DPR', 'Yemen',
                          football[team])

Let's just consider teams that have played more than five home and away games.

In [11]:
football["cnt_games_1"] = "COUNT(*) OVER (PARTITION BY home_team)"
football["cnt_games_2"] = "COUNT(*) OVER (PARTITION BY away_team)"
football.filter((football["cnt_games_2"] > 5) & (football["cnt_games_1"] > 5))
vp.drop("football_clean", relation_type = "table")
football.to_db(name = "football_clean",
               usecols = ["date", 
                          "home_score", 
                          "home_team", 
                          "tournament", 
                          "away_team", 
                          "away_score", 
                          "neutral", 
                          "country",
                          "city"],
               relation_type = "table",
               inplace = True)
177 elements were filtered
Out[11]:
📅
date
Date
123
home_score
Int
Abc
home_team
Varchar(64)
Abc
tournament
Varchar(84)
Abc
away_team
Varchar(64)
123
away_score
Int
010
neutral
Boolean
Abc
country
Varchar(64)
Abc
city
Varchar(56)
11872-11-300ScotlandFriendlyEngland0
ScotlandGlasgow
21873-03-084EnglandFriendlyScotland2
EnglandLondon
31874-03-072ScotlandFriendlyEngland1
ScotlandGlasgow
41875-03-062EnglandFriendlyScotland2
EnglandLondon
51876-03-043ScotlandFriendlyEngland0
ScotlandGlasgow
61876-03-254ScotlandFriendlyWales0
ScotlandGlasgow
71877-03-031EnglandFriendlyScotland3
EnglandLondon
81877-03-050WalesFriendlyScotland2
WalesWrexham
91878-03-027ScotlandFriendlyEngland2
ScotlandGlasgow
101878-03-239ScotlandFriendlyWales0
ScotlandGlasgow
111879-01-182EnglandFriendlyWales1
EnglandLondon
121879-04-055EnglandFriendlyScotland4
EnglandLondon
131879-04-070WalesFriendlyScotland3
WalesWrexham
141880-03-135ScotlandFriendlyEngland4
ScotlandGlasgow
151880-03-152WalesFriendlyEngland3
WalesWrexham
161880-03-275ScotlandFriendlyWales1
ScotlandGlasgow
171881-02-260EnglandFriendlyWales1
EnglandBlackburn
181881-03-121EnglandFriendlyScotland6
EnglandLondon
191881-03-141WalesFriendlyScotland5
WalesWrexham
201882-02-180Northern IrelandFriendlyEngland13
Republic of IrelandBelfast
211882-02-257WalesFriendlyNorthern Ireland1
WalesWrexham
221882-03-115ScotlandFriendlyEngland1
ScotlandGlasgow
231882-03-135WalesFriendlyEngland3
WalesWrexham
241882-03-255ScotlandFriendlyWales0
ScotlandGlasgow
251883-02-035EnglandFriendlyWales0
EnglandLondon
261883-02-247EnglandFriendlyNorthern Ireland0
EnglandLiverpool
271883-03-102EnglandFriendlyScotland3
EnglandSheffield
281883-03-120WalesFriendlyScotland3
WalesWrexham
291883-03-171Northern IrelandFriendlyWales1
Republic of IrelandBelfast
301884-01-260Northern IrelandBritish ChampionshipScotland5
Republic of IrelandBelfast
311884-02-096WalesBritish ChampionshipNorthern Ireland0
WalesWrexham
321884-02-231Northern IrelandBritish ChampionshipEngland8
Republic of IrelandBelfast
331884-03-151ScotlandBritish ChampionshipEngland0
ScotlandGlasgow
341884-03-170WalesBritish ChampionshipEngland4
WalesWrexham
351884-03-294ScotlandBritish ChampionshipWales1
ScotlandGlasgow
361885-02-284EnglandBritish ChampionshipNorthern Ireland0
EnglandManchester
371885-03-141EnglandBritish ChampionshipWales1
EnglandBlackburn
381885-03-148ScotlandBritish ChampionshipNorthern Ireland2
ScotlandGlasgow
391885-03-211EnglandBritish ChampionshipScotland1
EnglandLondon
401885-03-231WalesBritish ChampionshipScotland8
WalesWrexham
411885-04-112Northern IrelandBritish ChampionshipWales8
Republic of IrelandBelfast
421885-11-280United StatesFriendlyCanada1
United StatesNewark
431886-02-275WalesBritish ChampionshipNorthern Ireland0
WalesWrexham
441886-03-131Northern IrelandBritish ChampionshipEngland6
Republic of IrelandBelfast
451886-03-202Northern IrelandBritish ChampionshipScotland7
Republic of IrelandBelfast
461886-03-271ScotlandBritish ChampionshipEngland1
ScotlandGlasgow
471886-03-291WalesBritish ChampionshipEngland3
WalesWrexham
481886-04-104ScotlandBritish ChampionshipWales1
ScotlandGlasgow
491886-11-253United StatesFriendlyCanada2
United StatesNewark
501887-02-057EnglandBritish ChampionshipNorthern Ireland0
EnglandSheffield
511887-02-194ScotlandBritish ChampionshipNorthern Ireland1
ScotlandGlasgow
521887-02-264EnglandBritish ChampionshipWales0
EnglandLondon
531887-03-124Northern IrelandBritish ChampionshipWales1
Republic of IrelandBelfast
541887-03-192EnglandBritish ChampionshipScotland3
EnglandBlackburn
551887-03-210WalesBritish ChampionshipScotland2
WalesWrexham
561888-02-045EnglandBritish ChampionshipWales1
EnglandCrewe
571888-03-0311WalesBritish ChampionshipNorthern Ireland0
WalesWrexham
581888-03-105ScotlandBritish ChampionshipWales1
ScotlandEdinburgh
591888-03-170ScotlandBritish ChampionshipEngland5
ScotlandGlasgow
601888-03-242Northern IrelandBritish ChampionshipScotland10
Republic of IrelandBelfast
611888-04-071Northern IrelandBritish ChampionshipEngland5
Republic of IrelandBelfast
621888-09-194ScotlandFriendlyCanada0
ScotlandGlasgow
631889-02-234EnglandBritish ChampionshipWales1
EnglandStoke-on-Trent
641889-03-026EnglandBritish ChampionshipNorthern Ireland1
EnglandLiverpool
651889-03-097ScotlandBritish ChampionshipNorthern Ireland0
ScotlandGlasgow
661889-04-132EnglandBritish ChampionshipScotland3
EnglandLondon
671889-04-150WalesBritish ChampionshipScotland0
WalesWrexham
681889-04-271Northern IrelandBritish ChampionshipWales3
Republic of IrelandBelfast
691890-02-085WalesBritish ChampionshipNorthern Ireland2
EnglandShrewsbury
701890-03-151Northern IrelandBritish ChampionshipEngland9
Republic of IrelandBelfast
711890-03-151WalesBritish ChampionshipEngland3
WalesWrexham
721890-03-225ScotlandBritish ChampionshipWales0
ScotlandPaisley
731890-03-291Northern IrelandBritish ChampionshipScotland4
Republic of IrelandBelfast
741890-04-051ScotlandBritish ChampionshipEngland1
ScotlandGlasgow
751891-02-077Northern IrelandBritish ChampionshipWales2
Republic of IrelandBelfast
761891-03-074EnglandBritish ChampionshipWales1
EnglandSunderland
771891-03-076EnglandBritish ChampionshipNorthern Ireland1
EnglandWolverhampton
781891-03-213WalesBritish ChampionshipScotland4
WalesWrexham
791891-03-282ScotlandBritish ChampionshipNorthern Ireland1
ScotlandGlasgow
801891-04-062EnglandBritish ChampionshipScotland1
EnglandBlackburn
811892-02-271WalesBritish ChampionshipNorthern Ireland1
WalesBangor
821892-03-050Northern IrelandBritish ChampionshipEngland2
Republic of IrelandBelfast
831892-03-050WalesBritish ChampionshipEngland2
WalesWrexham
841892-03-192Northern IrelandBritish ChampionshipScotland3
Republic of IrelandBelfast
851892-03-266ScotlandBritish ChampionshipWales1
ScotlandEdinburgh
861892-04-021ScotlandBritish ChampionshipEngland4
ScotlandGlasgow
871893-02-256EnglandBritish ChampionshipNorthern Ireland1
EnglandBirmingham
881893-03-136EnglandBritish ChampionshipWales0
EnglandStoke-on-Trent
891893-03-180WalesBritish ChampionshipScotland8
WalesWrexham
901893-03-256ScotlandBritish ChampionshipNorthern Ireland1
ScotlandGlasgow
911893-04-015EnglandBritish ChampionshipScotland2
EnglandRichmond
921894-02-244WalesBritish ChampionshipNorthern Ireland1
WalesSwansea
931894-03-032Northern IrelandBritish ChampionshipEngland2
Republic of IrelandBelfast
941894-03-121WalesBritish ChampionshipEngland5
WalesWrexham
951894-03-245ScotlandBritish ChampionshipWales2
ScotlandKilmarnock
961894-03-311Northern IrelandBritish ChampionshipScotland2
Republic of IrelandBelfast
971894-04-072ScotlandBritish ChampionshipEngland2
ScotlandGlasgow
981895-03-099EnglandBritish ChampionshipNorthern Ireland0
EnglandDerby
991895-03-162Northern IrelandBritish ChampionshipWales2
Republic of IrelandBelfast
1001895-03-181EnglandBritish ChampionshipWales1
EnglandLondon
Rows: 1-100 | Columns: 9

A lot of things could influence the outcome of a game. Since we only have access to the score, teams, and type of game, we can't consider external factors like, weather or temperature, which would otherwise help our prediction.

To create a good model using this dataset, we could compute each team's key performance indicator (KPI), ranking (clusters computed using the number of games in important tournaments like the World Cup, the percentage of victory...), shape (moving windows using the last games information), and other factors.

Here's our plan:

  • Identify cup winners
  • Rank the teams with clustering
  • Compute teams' KPIs
  • Create a machine learning model

Data Preparation for Clustering

To create clusters, we need to find which teams are the winners of main tournaments (mainly the World Cups and Continental Cups). Since all tournaments took place the same year, we could partition by tournament and year to identify the last game of the tournament.

We'll ignore ties for our analysis since there's no way to determine a winner.

Cup Winner

Let's start by creating the feature 'winner' to indicate the winner of a game.

In [13]:
import verticapy.stats as st
football.filter(st.year(football["date"]) <= 2015)
football.case_when("winner",
                   football["home_score"] > football["away_score"], football["home_team"],
                   football["home_score"] < football["away_score"], football["away_team"],
                   None)
3884 elements were filtered
Out[13]:
📅
date
Date
123
home_score
Int
Abc
home_team
Varchar(64)
Abc
tournament
Varchar(84)
Abc
away_team
Varchar(64)
123
away_score
Int
010
neutral
Boolean
Abc
country
Varchar(64)
Abc
city
Varchar(56)
Abc
winner
Varchar(64)
11872-11-300ScotlandFriendlyEngland0
ScotlandGlasgow[null]
21873-03-084EnglandFriendlyScotland2
EnglandLondonEngland
31874-03-072ScotlandFriendlyEngland1
ScotlandGlasgowScotland
41875-03-062EnglandFriendlyScotland2
EnglandLondon[null]
51876-03-043ScotlandFriendlyEngland0
ScotlandGlasgowScotland
61876-03-254ScotlandFriendlyWales0
ScotlandGlasgowScotland
71877-03-031EnglandFriendlyScotland3
EnglandLondonScotland
81877-03-050WalesFriendlyScotland2
WalesWrexhamScotland
91878-03-027ScotlandFriendlyEngland2
ScotlandGlasgowScotland
101878-03-239ScotlandFriendlyWales0
ScotlandGlasgowScotland
111879-01-182EnglandFriendlyWales1
EnglandLondonEngland
121879-04-055EnglandFriendlyScotland4
EnglandLondonEngland
131879-04-070WalesFriendlyScotland3
WalesWrexhamScotland
141880-03-135ScotlandFriendlyEngland4
ScotlandGlasgowScotland
151880-03-152WalesFriendlyEngland3
WalesWrexhamEngland
161880-03-275ScotlandFriendlyWales1
ScotlandGlasgowScotland
171881-02-260EnglandFriendlyWales1
EnglandBlackburnWales
181881-03-121EnglandFriendlyScotland6
EnglandLondonScotland
191881-03-141WalesFriendlyScotland5
WalesWrexhamScotland
201882-02-180Northern IrelandFriendlyEngland13
Republic of IrelandBelfastEngland
211882-02-257WalesFriendlyNorthern Ireland1
WalesWrexhamWales
221882-03-115ScotlandFriendlyEngland1
ScotlandGlasgowScotland
231882-03-135WalesFriendlyEngland3
WalesWrexhamWales
241882-03-255ScotlandFriendlyWales0
ScotlandGlasgowScotland
251883-02-035EnglandFriendlyWales0
EnglandLondonEngland
261883-02-247EnglandFriendlyNorthern Ireland0
EnglandLiverpoolEngland
271883-03-102EnglandFriendlyScotland3
EnglandSheffieldScotland
281883-03-120WalesFriendlyScotland3
WalesWrexhamScotland
291883-03-171Northern IrelandFriendlyWales1
Republic of IrelandBelfast[null]
301884-01-260Northern IrelandBritish ChampionshipScotland5
Republic of IrelandBelfastScotland
311884-02-096WalesBritish ChampionshipNorthern Ireland0
WalesWrexhamWales
321884-02-231Northern IrelandBritish ChampionshipEngland8
Republic of IrelandBelfastEngland
331884-03-151ScotlandBritish ChampionshipEngland0
ScotlandGlasgowScotland
341884-03-170WalesBritish ChampionshipEngland4
WalesWrexhamEngland
351884-03-294ScotlandBritish ChampionshipWales1
ScotlandGlasgowScotland
361885-02-284EnglandBritish ChampionshipNorthern Ireland0
EnglandManchesterEngland
371885-03-141EnglandBritish ChampionshipWales1
EnglandBlackburn[null]
381885-03-148ScotlandBritish ChampionshipNorthern Ireland2
ScotlandGlasgowScotland
391885-03-211EnglandBritish ChampionshipScotland1
EnglandLondon[null]
401885-03-231WalesBritish ChampionshipScotland8
WalesWrexhamScotland
411885-04-112Northern IrelandBritish ChampionshipWales8
Republic of IrelandBelfastWales
421885-11-280United StatesFriendlyCanada1
United StatesNewarkCanada
431886-02-275WalesBritish ChampionshipNorthern Ireland0
WalesWrexhamWales
441886-03-131Northern IrelandBritish ChampionshipEngland6
Republic of IrelandBelfastEngland
451886-03-202Northern IrelandBritish ChampionshipScotland7
Republic of IrelandBelfastScotland
461886-03-271ScotlandBritish ChampionshipEngland1
ScotlandGlasgow[null]
471886-03-291WalesBritish ChampionshipEngland3
WalesWrexhamEngland
481886-04-104ScotlandBritish ChampionshipWales1
ScotlandGlasgowScotland
491886-11-253United StatesFriendlyCanada2
United StatesNewarkUnited States
501887-02-057EnglandBritish ChampionshipNorthern Ireland0
EnglandSheffieldEngland
511887-02-194ScotlandBritish ChampionshipNorthern Ireland1
ScotlandGlasgowScotland
521887-02-264EnglandBritish ChampionshipWales0
EnglandLondonEngland
531887-03-124Northern IrelandBritish ChampionshipWales1
Republic of IrelandBelfastNorthern Ireland
541887-03-192EnglandBritish ChampionshipScotland3
EnglandBlackburnScotland
551887-03-210WalesBritish ChampionshipScotland2
WalesWrexhamScotland
561888-02-045EnglandBritish ChampionshipWales1
EnglandCreweEngland
571888-03-0311WalesBritish ChampionshipNorthern Ireland0
WalesWrexhamWales
581888-03-105ScotlandBritish ChampionshipWales1
ScotlandEdinburghScotland
591888-03-170ScotlandBritish ChampionshipEngland5
ScotlandGlasgowEngland
601888-03-242Northern IrelandBritish ChampionshipScotland10
Republic of IrelandBelfastScotland
611888-04-071Northern IrelandBritish ChampionshipEngland5
Republic of IrelandBelfastEngland
621888-09-194ScotlandFriendlyCanada0
ScotlandGlasgowScotland
631889-02-234EnglandBritish ChampionshipWales1
EnglandStoke-on-TrentEngland
641889-03-026EnglandBritish ChampionshipNorthern Ireland1
EnglandLiverpoolEngland
651889-03-097ScotlandBritish ChampionshipNorthern Ireland0
ScotlandGlasgowScotland
661889-04-132EnglandBritish ChampionshipScotland3
EnglandLondonScotland
671889-04-150WalesBritish ChampionshipScotland0
WalesWrexham[null]
681889-04-271Northern IrelandBritish ChampionshipWales3
Republic of IrelandBelfastWales
691890-02-085WalesBritish ChampionshipNorthern Ireland2
EnglandShrewsburyWales
701890-03-151Northern IrelandBritish ChampionshipEngland9
Republic of IrelandBelfastEngland
711890-03-151WalesBritish ChampionshipEngland3
WalesWrexhamEngland
721890-03-225ScotlandBritish ChampionshipWales0
ScotlandPaisleyScotland
731890-03-291Northern IrelandBritish ChampionshipScotland4
Republic of IrelandBelfastScotland
741890-04-051ScotlandBritish ChampionshipEngland1
ScotlandGlasgow[null]
751891-02-077Northern IrelandBritish ChampionshipWales2
Republic of IrelandBelfastNorthern Ireland
761891-03-074EnglandBritish ChampionshipWales1
EnglandSunderlandEngland
771891-03-076EnglandBritish ChampionshipNorthern Ireland1
EnglandWolverhamptonEngland
781891-03-213WalesBritish ChampionshipScotland4
WalesWrexhamScotland
791891-03-282ScotlandBritish ChampionshipNorthern Ireland1
ScotlandGlasgowScotland
801891-04-062EnglandBritish ChampionshipScotland1
EnglandBlackburnEngland
811892-02-271WalesBritish ChampionshipNorthern Ireland1
WalesBangor[null]
821892-03-050Northern IrelandBritish ChampionshipEngland2
Republic of IrelandBelfastEngland
831892-03-050WalesBritish ChampionshipEngland2
WalesWrexhamEngland
841892-03-192Northern IrelandBritish ChampionshipScotland3
Republic of IrelandBelfastScotland
851892-03-266ScotlandBritish ChampionshipWales1
ScotlandEdinburghScotland
861892-04-021ScotlandBritish ChampionshipEngland4
ScotlandGlasgowEngland
871893-02-256EnglandBritish ChampionshipNorthern Ireland1
EnglandBirminghamEngland
881893-03-136EnglandBritish ChampionshipWales0
EnglandStoke-on-TrentEngland
891893-03-180WalesBritish ChampionshipScotland8
WalesWrexhamScotland
901893-03-256ScotlandBritish ChampionshipNorthern Ireland1
ScotlandGlasgowScotland
911893-04-015EnglandBritish ChampionshipScotland2
EnglandRichmondEngland
921894-02-244WalesBritish ChampionshipNorthern Ireland1
WalesSwanseaWales
931894-03-032Northern IrelandBritish ChampionshipEngland2
Republic of IrelandBelfast[null]
941894-03-121WalesBritish ChampionshipEngland5
WalesWrexhamEngland
951894-03-245ScotlandBritish ChampionshipWales2
ScotlandKilmarnockScotland
961894-03-311Northern IrelandBritish ChampionshipScotland2
Republic of IrelandBelfastScotland
971894-04-072ScotlandBritish ChampionshipEngland2
ScotlandGlasgow[null]
981895-03-099EnglandBritish ChampionshipNorthern Ireland0
EnglandDerbyEngland
991895-03-162Northern IrelandBritish ChampionshipWales2
Republic of IrelandBelfast[null]
1001895-03-181EnglandBritish ChampionshipWales1
EnglandLondon[null]
Rows: 1-100 of 37525 | Columns: 10

Let's analyze the last game of each tournament.

In [14]:
football["year"] = st.year(football["date"])
football.analytic('row_number', 
                  order_by = {"date": "desc"}, 
                  by = ["tournament", "year"] , 
                  name = "order_tournament")
Out[14]:
📅
date
Date
123
home_score
Int
Abc
home_team
Varchar(64)
Abc
tournament
Varchar(84)
Abc
away_team
Varchar(64)
123
away_score
Int
010
neutral
Boolean
Abc
country
Varchar(64)
Abc
city
Varchar(56)
Abc
winner
Varchar(64)
123
year
Integer
123
order_tournament
Integer
12010-10-313ArubaABCS TournamentBonaire3
CuraçaoWillemstad[null]20101
22010-10-312CuraçaoABCS TournamentSuriname2
CuraçaoWillemstad[null]20102
32010-10-294SurinameABCS TournamentBonaire2
CuraçaoWillemstadSuriname20103
42010-10-293CuraçaoABCS TournamentAruba0
CuraçaoWillemstadCuraçao20104
52011-12-042SurinameABCS TournamentCuraçao0
SurinameParamariboSuriname20111
62011-12-042BonaireABCS TournamentAruba2
SurinameParamaribo[null]20112
72011-12-021CuraçaoABCS TournamentBonaire3
SurinameParamariboBonaire20113
82011-12-020SurinameABCS TournamentAruba0
SurinameParamaribo[null]20114
92012-07-152BonaireABCS TournamentCuraçao9
ArubaOranjestadCuraçao20121
102012-07-151ArubaABCS TournamentSuriname0
ArubaOranjestadAruba20122
112012-07-138SurinameABCS TournamentBonaire0
ArubaOranjestadSuriname20123
122012-07-133ArubaABCS TournamentCuraçao2
ArubaOranjestadAruba20124
132013-11-161CuraçaoABCS TournamentSuriname3
CuraçaoWillemstadSuriname20131
142013-11-161ArubaABCS TournamentBonaire2
CuraçaoWillemstadBonaire20132
152013-11-142CuraçaoABCS TournamentAruba0
CuraçaoWillemstadCuraçao20133
162013-11-140BonaireABCS TournamentSuriname2
CuraçaoWillemstadSuriname20134
172015-02-014CuraçaoABCS TournamentBonaire1
SurinameParamariboCuraçao20151
182015-02-011SurinameABCS TournamentAruba0
SurinameParamariboSuriname20152
192015-01-303SurinameABCS TournamentBonaire0
SurinameParamariboSuriname20153
202015-01-300CuraçaoABCS TournamentAruba0
SurinameParamaribo[null]20154
211956-09-155South KoreaAFC Asian CupVietnam Republic3
Hong KongSo Kon PoSouth Korea19561
221956-09-122IsraelAFC Asian CupVietnam Republic1
Hong KongSo Kon PoIsrael19562
231956-09-092Hong KongAFC Asian CupVietnam Republic2
Hong KongSo Kon Po[null]19563
241956-09-081IsraelAFC Asian CupSouth Korea2
Hong KongSo Kon PoSouth Korea19564
251956-09-062Hong KongAFC Asian CupSouth Korea2
Hong KongSo Kon Po[null]19565
261956-09-012Hong KongAFC Asian CupIsrael3
Hong KongSo Kon PoIsrael19566
271960-10-211South KoreaAFC Asian CupChinese Taipei0
South KoreaSeoulSouth Korea19601
281960-10-201IsraelAFC Asian CupChinese Taipei0
South KoreaSeoulIsrael19602
291960-10-195IsraelAFC Asian CupVietnam Republic1
South KoreaSeoulIsrael19603
301960-10-173South KoreaAFC Asian CupIsrael0
South KoreaSeoulSouth Korea19604
311960-10-172Chinese TaipeiAFC Asian CupVietnam Republic0
South KoreaSeoulChinese Taipei19605
321960-10-145South KoreaAFC Asian CupVietnam Republic1
South KoreaSeoulSouth Korea19606
331964-06-032IsraelAFC Asian CupSouth Korea1
IsraelRamat-GanIsrael19641
341964-06-021Hong KongAFC Asian CupIndia3
IsraelJaffaIndia19642
351964-05-310Hong KongAFC Asian CupSouth Korea1
IsraelJerusalemSouth Korea19643
361964-05-292IsraelAFC Asian CupIndia0
IsraelJaffaIsrael19644
371964-05-272IndiaAFC Asian CupSouth Korea0
IsraelHaifaIndia19645
381964-05-261IsraelAFC Asian CupHong Kong0
IsraelRamat-GanIsrael19646
391968-05-192IranAFC Asian CupIsrael1
IranTeheranIran19681
401968-05-182BurmaAFC Asian CupHong Kong0
IranTeheranBurma19682
411968-05-174IsraelAFC Asian CupChinese Taipei1
IranTeheranIsrael19683
421968-05-163IranAFC Asian CupBurma1
IranTeheranIran19684
431968-05-151Hong KongAFC Asian CupChinese Taipei1
IranTeheran[null]19685
441968-05-141BurmaAFC Asian CupIsrael0
IranTeheranBurma19686
451968-05-134IranAFC Asian CupChinese Taipei0
IranTeheranIran19687
461968-05-121Hong KongAFC Asian CupIsrael6
IranTeheranIsrael19688
471968-05-111BurmaAFC Asian CupChinese Taipei1
IranTeheran[null]19689
481968-05-102IranAFC Asian CupHong Kong0
IranTeheranIran196810
491972-05-192ThailandAFC Asian CupCambodia2
ThailandBangkok[null]19721
501972-05-192IranAFC Asian CupSouth Korea1
ThailandBangkokIran19722
511972-05-171ThailandAFC Asian CupSouth Korea1
ThailandBangkok[null]19723
521972-05-162IranAFC Asian CupCambodia1
ThailandBangkokIran19724
531972-05-144CambodiaAFC Asian CupKuwait0
ThailandBangkokCambodia19725
541972-05-132ThailandAFC Asian CupIran3
ThailandBangkokIran19726
551972-05-121South KoreaAFC Asian CupKuwait2
ThailandBangkokKuwait19727
561972-05-111ThailandAFC Asian CupIraq1
ThailandBangkok[null]19728
571972-05-101CambodiaAFC Asian CupSouth Korea4
ThailandBangkokSouth Korea19729
581972-05-093IranAFC Asian CupIraq0
ThailandBangkokIran197210
591972-05-080ThailandAFC Asian CupKuwait2
ThailandBangkokKuwait197211
601972-05-072IranAFC Asian CupCambodia0
ThailandBangkokIran197212
611972-05-070South KoreaAFC Asian CupIraq0
ThailandBangkok[null]197213
621976-06-131IranAFC Asian CupKuwait0
IranTeheranIran19761
631976-06-131China PRAFC Asian CupIraq0
IranTeheranChina PR19762
641976-06-102IraqAFC Asian CupKuwait3
IranTeheranKuwait19763
651976-06-102IranAFC Asian CupChina PR0
IranTeheranIran19764
661976-06-088IranAFC Asian CupYemen0
IranTeheranIran19765
671976-06-070China PRAFC Asian CupKuwait1
IranTeheranKuwait19766
681976-06-061IraqAFC Asian CupYemen0
IranTeheranIraq19767
691976-06-051China PRAFC Asian CupMalaysia1
IranTeheran[null]19768
701976-06-042IranAFC Asian CupIraq0
IranTeheranIran19769
711976-06-032KuwaitAFC Asian CupMalaysia0
IranTeheranKuwait197610
721980-09-303KuwaitAFC Asian CupSouth Korea0
KuwaitKuwait CityKuwait19801
731980-09-293IranAFC Asian CupNorth Korea0
KuwaitKuwait CityIran19802
741980-09-282South KoreaAFC Asian CupNorth Korea1
KuwaitKuwait CitySouth Korea19803
751980-09-282KuwaitAFC Asian CupIran1
KuwaitKuwait CityKuwait19804
761980-09-261SyriaAFC Asian CupNorth Korea2
KuwaitKuwait CityNorth Korea19805
771980-09-256China PRAFC Asian CupBangladesh0
KuwaitKuwait CityChina PR19806
781980-09-254KuwaitAFC Asian CupQatar0
KuwaitKuwait CityKuwait19807
791980-09-244South KoreaAFC Asian CupUnited Arab Emirates1
KuwaitKuwait CitySouth Korea19808
801980-09-243IranAFC Asian CupNorth Korea2
KuwaitKuwait CityIran19809
811980-09-231SyriaAFC Asian CupChina PR0
KuwaitKuwait CitySyria198010
821980-09-231MalaysiaAFC Asian CupQatar1
KuwaitKuwait City[null]198011
831980-09-220BangladeshAFC Asian CupIran7
KuwaitKuwait CityIran198012
841980-09-210KuwaitAFC Asian CupSouth Korea3
KuwaitKuwait CitySouth Korea198013
851980-09-202China PRAFC Asian CupIran2
KuwaitKuwait City[null]198014
861980-09-200United Arab EmiratesAFC Asian CupMalaysia2
KuwaitKuwait CityMalaysia198015
871980-09-190QatarAFC Asian CupSouth Korea2
KuwaitKuwait CitySouth Korea198016
881980-09-190BangladeshAFC Asian CupSyria1
KuwaitKuwait CitySyria198017
891980-09-183KuwaitAFC Asian CupMalaysia1
KuwaitKuwait CityKuwait198018
901980-09-182North KoreaAFC Asian CupChina PR1
KuwaitKuwait CityNorth Korea198019
911980-09-172QatarAFC Asian CupUnited Arab Emirates1
KuwaitKuwait CityQatar198020
921980-09-170IranAFC Asian CupSyria0
KuwaitKuwait City[null]198021
931980-09-163North KoreaAFC Asian CupBangladesh2
KuwaitKuwait CityNorth Korea198022
941980-09-161MalaysiaAFC Asian CupSouth Korea1
KuwaitKuwait City[null]198023
951980-09-151KuwaitAFC Asian CupUnited Arab Emirates1
KuwaitKuwait City[null]198024
961984-12-162Saudi ArabiaAFC Asian CupChina PR0
SingaporeKallangSaudi Arabia19841
971984-12-161IranAFC Asian CupKuwait1
SingaporeKallang[null]19842
981984-12-140KuwaitAFC Asian CupChina PR1
SingaporeKallangChina PR19843
991984-12-131Saudi ArabiaAFC Asian CupIran1
SingaporeKallang[null]19844
1001984-12-115China PRAFC Asian CupUnited Arab Emirates0
SingaporeKallangChina PR19845
Rows: 1-100 of 37525 | Columns: 12

We can filter the data by only considering the last games and top tournaments.

In [15]:
football.filter(conditions = [football["order_tournament"] == 1,
                              football["winner"] != None,
                              football["tournament"]._in(["FIFA World Cup", 
                                                          "UEFA Euro", 
                                                          "Copa América", 
                                                          "African Cup of Nations",
                                                          "AFC Asian Cup",
                                                          "Gold Cup"])])
37418 elements were filtered
Out[15]:
📅
date
Date
123
home_score
Int
Abc
home_team
Varchar(64)
Abc
tournament
Varchar(84)
Abc
away_team
Varchar(64)
123
away_score
Int
010
neutral
Boolean
Abc
country
Varchar(64)
Abc
city
Varchar(56)
Abc
winner
Varchar(64)
123
year
Integer
123
order_tournament
Integer
11956-09-155South KoreaAFC Asian CupVietnam Republic3
Hong KongSo Kon PoSouth Korea19561
21960-10-211South KoreaAFC Asian CupChinese Taipei0
South KoreaSeoulSouth Korea19601
31964-06-032IsraelAFC Asian CupSouth Korea1
IsraelRamat-GanIsrael19641
41968-05-192IranAFC Asian CupIsrael1
IranTeheranIran19681
51972-05-192IranAFC Asian CupSouth Korea1
ThailandBangkokIran19721
61976-06-131China PRAFC Asian CupIraq0
IranTeheranChina PR19761
71980-09-303KuwaitAFC Asian CupSouth Korea0
KuwaitKuwait CityKuwait19801
82000-10-290China PRAFC Asian CupSouth Korea1
LebanonBeirutSouth Korea20001
92004-08-071China PRAFC Asian CupJapan3
China PRBeijingJapan20041
102007-07-291IraqAFC Asian CupSaudi Arabia0
IndonesiaJakartaIraq20071
112011-01-290AustraliaAFC Asian CupJapan1
QatarDohaJapan20111
122015-01-312AustraliaAFC Asian CupSouth Korea1
AustraliaSydneyAustralia20151
131957-02-164EgyptAfrican Cup of NationsEthiopia0
SudanKhartoumEgypt19571
141959-05-292EgyptAfrican Cup of NationsSudan1
United Arab RepublicCairoEgypt19591
151962-01-214EthiopiaAfrican Cup of NationsEgypt2
EthiopiaAddis AbebaEthiopia19621
161963-12-013GhanaAfrican Cup of NationsSudan0
GhanaAccraGhana19631
171965-11-211Ivory CoastAfrican Cup of NationsSenegal0
TunisiaTunisIvory Coast19651
181968-01-210EthiopiaAfrican Cup of NationsIvory Coast1
EthiopiaAddis AbebaIvory Coast19681
191970-02-161SudanAfrican Cup of NationsGhana0
SudanKhartoumSudan19701
201972-03-053CongoAfrican Cup of NationsMali2
CameroonYaoundéCongo19721
211974-03-142DR CongoAfrican Cup of NationsZambia0
EgyptCairoDR Congo19741
221978-03-162GhanaAfrican Cup of NationsUganda0
GhanaAccraGhana19781
231980-03-223NigeriaAfrican Cup of NationsAlgeria0
NigeriaLagosNigeria19801
241984-03-183CameroonAfrican Cup of NationsNigeria1
Ivory CoastAbidjanCameroon19841
251988-03-271CameroonAfrican Cup of NationsNigeria0
MoroccoCasablancaCameroon19881
261990-03-161AlgeriaAfrican Cup of NationsNigeria0
AlgeriaAlgiersAlgeria19901
271994-04-102NigeriaAfrican Cup of NationsZambia1
TunisiaTunisNigeria19941
281996-02-031ZambiaAfrican Cup of NationsGhana0
South AfricaJohannesburgZambia19961
291998-02-280South AfricaAfrican Cup of NationsEgypt2
Burkina FasoOuagadougouEgypt19981
302004-02-142TunisiaAfrican Cup of NationsMorocco1
TunisiaRadèsTunisia20041
312008-02-100CameroonAfrican Cup of NationsEgypt1
GhanaAccraEgypt20081
322010-01-310GhanaAfrican Cup of NationsEgypt1
AngolaLuandaEgypt20101
332013-02-101NigeriaAfrican Cup of NationsBurkina Faso0
South AfricaJohannesburgNigeria20131
341917-10-141UruguayCopa AméricaArgentina0
UruguayMontevideoUruguay19171
351919-05-291BrazilCopa AméricaUruguay0
BrazilRio de JaneiroBrazil19191
361920-10-031ChileCopa AméricaUruguay2
ChileViña del MarUruguay19201
371921-10-301ArgentinaCopa AméricaUruguay0
ArgentinaBuenos AiresArgentina19211
381922-10-223BrazilCopa AméricaParaguay0
BrazilRio de JaneiroBrazil19221
391923-12-022UruguayCopa AméricaArgentina0
UruguayMontevideoUruguay19231
401926-11-035ChileCopa AméricaParaguay1
ChileSantiagoChile19261
411927-11-271PeruCopa AméricaArgentina5
PeruLimaArgentina19271
421929-11-172ArgentinaCopa AméricaUruguay0
ArgentinaBuenos AiresArgentina19291
431935-01-270ArgentinaCopa AméricaUruguay3
PeruLimaUruguay19351
441936-12-302ArgentinaCopa AméricaChile1
ArgentinaBuenos AiresArgentina19361
451937-02-012ArgentinaCopa AméricaBrazil0
ArgentinaBuenos AiresArgentina19371
461939-02-121EcuadorCopa AméricaParaguay3
PeruLimaParaguay19391
471941-03-040ChileCopa AméricaArgentina1
ChileSantiagoArgentina19411
481945-02-280ChileCopa AméricaBrazil1
ChileSantiagoBrazil19451
491946-02-102ArgentinaCopa AméricaBrazil0
ArgentinaBuenos AiresArgentina19461
501947-12-313BoliviaCopa AméricaChile4
EcuadorGuayaquilChile19471
511949-05-117BrazilCopa AméricaParaguay0
BrazilRio de JaneiroBrazil19491
521953-04-012BrazilCopa AméricaParaguay3
PeruLimaParaguay19531
531956-02-151UruguayCopa AméricaArgentina0
UruguayMontevideoUruguay19561
541957-04-062PeruCopa AméricaArgentina1
PeruLimaPeru19571
551959-12-253EcuadorCopa AméricaParaguay1
EcuadorGuayaquilEcuador19591
561966-12-283ParaguayCopa AméricaEcuador1
ParaguayAsunciónParaguay19661
571967-02-021UruguayCopa AméricaArgentina0
UruguayMontevideoUruguay19671
581975-10-280ColombiaCopa AméricaPeru1
VenezuelaCaracasPeru19751
591987-07-120ChileCopa AméricaUruguay1
ArgentinaBuenos AiresUruguay19871
601991-07-210ChileCopa AméricaBrazil2
ChileSantiagoBrazil19911
611993-07-042ArgentinaCopa AméricaMexico1
EcuadorGuayaquilArgentina19931
621997-06-291BoliviaCopa AméricaBrazil3
BoliviaLa PazBrazil19971
631999-07-183BrazilCopa AméricaUruguay0
ParaguayAsunciónBrazil19991
642001-07-291ColombiaCopa AméricaMexico0
ColombiaBogotáColombia20011
652007-07-153BrazilCopa AméricaArgentina0
VenezuelaMaracaiboBrazil20071
662011-07-243UruguayCopa AméricaParaguay0
ArgentinaBuenos AiresUruguay20111
671930-07-304UruguayFIFA World CupArgentina2
UruguayMontevideoUruguay19301
681934-06-102ItalyFIFA World CupCzech Republic1
ItalyRomeItaly19341
691938-06-192HungaryFIFA World CupItaly4
FranceColombesItaly19381
701950-07-161BrazilFIFA World CupUruguay2
BrazilRio de JaneiroUruguay19501
711954-07-043GermanyFIFA World CupHungary2
SwitzerlandBerneGermany19541
721958-06-292SwedenFIFA World CupBrazil5
SwedenSolnaBrazil19581
731962-06-173BrazilFIFA World CupCzech Republic1
ChileSantiagoBrazil19621
741966-07-304EnglandFIFA World CupGermany2
EnglandLondonEngland19661
751970-06-214BrazilFIFA World CupItaly1
MexicoMexico CityBrazil19701
761974-07-072GermanyFIFA World CupNetherlands1
GermanyMunichGermany19741
771978-06-253ArgentinaFIFA World CupNetherlands1
ArgentinaBuenos AiresArgentina19781
781982-07-113ItalyFIFA World CupGermany1
SpainMadridItaly19821
791986-06-293ArgentinaFIFA World CupGermany2
MexicoMexico CityArgentina19861
801990-07-081GermanyFIFA World CupArgentina0
ItalyRomeGermany19901
811998-07-123FranceFIFA World CupBrazil0
FranceSaint-DenisFrance19981
822002-06-300GermanyFIFA World CupBrazil2
JapanYokohamaBrazil20021
832010-07-110NetherlandsFIFA World CupSpain1
South AfricaJohannesburgSpain20101
842014-07-131GermanyFIFA World CupArgentina0
BrazilRio de JaneiroGermany20141
851996-01-212MexicoGold CupBrazil0
United StatesLos AngelesMexico19961
861998-02-150United StatesGold CupMexico1
United StatesLos AngelesMexico19981
872000-02-272CanadaGold CupColombia0
United StatesLos AngelesCanada20001
882002-02-022CanadaGold CupSouth Korea1
United StatesPasadenaCanada20021
892003-07-271MexicoGold CupBrazil0
MexicoMexico CityMexico20031
902007-06-242United StatesGold CupMexico1
United StatesChicagoUnited States20071
912009-07-260United StatesGold CupMexico5
United StatesEast RutherfordMexico20091
922011-06-252United StatesGold CupMexico4
United StatesPasadenaMexico20111
932013-07-281United StatesGold CupPanama0
United StatesChicagoUnited States20131
942015-07-261JamaicaGold CupMexico3
United StatesPhiladelphiaMexico20151
951960-07-102RussiaUEFA EuroSerbia1
FranceParisRussia19601
961964-06-212SpainUEFA EuroRussia1
SpainMadridSpain19641
971968-06-102ItalyUEFA EuroSerbia0
ItalyRomeItaly19681
981972-06-183GermanyUEFA EuroRussia0
BelgiumBrusselsGermany19721
991980-06-221BelgiumUEFA EuroGermany2
ItalyRomeGermany19801
1001984-06-272FranceUEFA EuroSpain0
FranceParisFrance19841
Rows: 1-100 of 107 | Columns: 12

Let's consider the World Cup as a special tournament. It is the only one where the confrontations between the top teams is possible.

In [16]:
football["Word_Cup"] = st.decode(football["tournament"], 
                                 "FIFA World Cup", 1, 0)

We can compute all the number of cup-wins by team. As expected, Brazil and Germany are the top football teams.

In [17]:
agg = [st.sum(football["Word_Cup"])._as("nb_World_Cup"),
       st.sum(1 - football["Word_Cup"])._as("nb_Continental_Cup")]
football_cup_winners = football.groupby(["winner"], agg)
football_cup_winners.sort({"nb_World_Cup": "desc",
                           "nb_Continental_Cup": "desc"}).head(10)
Out[17]:
Abc
winner
Varchar(64)
123
nb_World_Cup
Integer
123
nb_Continental_Cup
Integer
1Brazil48
2Germany43
3Italy31
4Uruguay28
5Argentina28
6Spain13
7France12
8England10
9Mexico06
10Egypt05
Rows: 1-10 | Columns: 3

Let's export the result to our Vertica database.

In [19]:
vp.drop("football_cup_winners", relation_type = "table")
football_cup_winners.to_db("football_cup_winners", 
                           relation_type = "table")
Out[19]:
Abc
winner
Varchar(64)
123
nb_World_Cup
Integer
123
nb_Continental_Cup
Integer
1Brazil48
2Germany43
3Italy31
4Uruguay28
5Argentina28
6Spain13
7France12
8England10
9Mexico06
10Egypt05
11Paraguay03
12Nigeria03
13South Korea03
14Peru02
15Canada02
16Cameroon02
17Iran02
18Japan02
19Chile02
20Ivory Coast02
21Ghana02
22United States02
23Israel01
24Algeria01
25Netherlands01
26Australia01
27China PR01
28DR Congo01
29Denmark01
30Congo01
31Iraq01
32Ecuador01
33Kuwait01
34Colombia01
35Ethiopia01
36Zambia01
37Tunisia01
38Russia01
39Sudan01
40Greece01
Rows: 1-40 | Columns: 3

Team Confederations

Looking into team confederations could help our analysis. For example, this might help us quantify skill differences between different continents. A team that had played a qualification of a specific location can only belong to that tournament confederation.

First let's encode the different continents so we can compute the correct aggregations.

In [20]:
football = vp.read_csv("data/football.csv")
football.case_when('confederation', 
                   football["tournament"] == 'UEFA Euro qualification', 5,
                   football["tournament"] == 'African Cup of Nations qualification', 4,
                   football["tournament"] == 'AFC Asian Cup qualification', 3,
                   football["tournament"] == 'Copa América', 2,
                   football["tournament"] == 'Gold Cup', 1, 0)
Out[20]:
📅
date
Date
Abc
home_team
Varchar(64)
Abc
away_team
Varchar(64)
123
home_score
Int
123
away_score
Int
Abc
tournament
Varchar(84)
Abc
city
Varchar(56)
Abc
country
Varchar(64)
010
neutral
Boolean
123
confederation
Integer
11872-11-30ScotlandEngland00FriendlyGlasgowScotland
0
21873-03-08EnglandScotland42FriendlyLondonEngland
0
31874-03-07ScotlandEngland21FriendlyGlasgowScotland
0
41875-03-06EnglandScotland22FriendlyLondonEngland
0
51876-03-04ScotlandEngland30FriendlyGlasgowScotland
0
61876-03-25ScotlandWales40FriendlyGlasgowScotland
0
71877-03-03EnglandScotland13FriendlyLondonEngland
0
81877-03-05WalesScotland02FriendlyWrexhamWales
0
91878-03-02ScotlandEngland72FriendlyGlasgowScotland
0
101878-03-23ScotlandWales90FriendlyGlasgowScotland
0
111879-01-18EnglandWales21FriendlyLondonEngland
0
121879-04-05EnglandScotland54FriendlyLondonEngland
0
131879-04-07WalesScotland03FriendlyWrexhamWales
0
141880-03-13ScotlandEngland54FriendlyGlasgowScotland
0
151880-03-15WalesEngland23FriendlyWrexhamWales
0
161880-03-27ScotlandWales51FriendlyGlasgowScotland
0
171881-02-26EnglandWales01FriendlyBlackburnEngland
0
181881-03-12EnglandScotland16FriendlyLondonEngland
0
191881-03-14WalesScotland15FriendlyWrexhamWales
0
201882-02-18Northern IrelandEngland013FriendlyBelfastRepublic of Ireland
0
211882-02-25WalesNorthern Ireland71FriendlyWrexhamWales
0
221882-03-11ScotlandEngland51FriendlyGlasgowScotland
0
231882-03-13WalesEngland53FriendlyWrexhamWales
0
241882-03-25ScotlandWales50FriendlyGlasgowScotland
0
251883-02-03EnglandWales50FriendlyLondonEngland
0
261883-02-24EnglandNorthern Ireland70FriendlyLiverpoolEngland
0
271883-03-10EnglandScotland23FriendlySheffieldEngland
0
281883-03-12WalesScotland03FriendlyWrexhamWales
0
291883-03-17Northern IrelandWales11FriendlyBelfastRepublic of Ireland
0
301884-01-26Northern IrelandScotland05British ChampionshipBelfastRepublic of Ireland
0
311884-02-09WalesNorthern Ireland60British ChampionshipWrexhamWales
0
321884-02-23Northern IrelandEngland18British ChampionshipBelfastRepublic of Ireland
0
331884-03-15ScotlandEngland10British ChampionshipGlasgowScotland
0
341884-03-17WalesEngland04British ChampionshipWrexhamWales
0
351884-03-29ScotlandWales41British ChampionshipGlasgowScotland
0
361885-02-28EnglandNorthern Ireland40British ChampionshipManchesterEngland
0
371885-03-14EnglandWales11British ChampionshipBlackburnEngland
0
381885-03-14ScotlandNorthern Ireland82British ChampionshipGlasgowScotland
0
391885-03-21EnglandScotland11British ChampionshipLondonEngland
0
401885-03-23WalesScotland18British ChampionshipWrexhamWales
0
411885-04-11Northern IrelandWales28British ChampionshipBelfastRepublic of Ireland
0
421885-11-28United StatesCanada01FriendlyNewarkUnited States
0
431886-02-27WalesNorthern Ireland50British ChampionshipWrexhamWales
0
441886-03-13Northern IrelandEngland16British ChampionshipBelfastRepublic of Ireland
0
451886-03-20Northern IrelandScotland27British ChampionshipBelfastRepublic of Ireland
0
461886-03-27ScotlandEngland11British ChampionshipGlasgowScotland
0
471886-03-29WalesEngland13British ChampionshipWrexhamWales
0
481886-04-10ScotlandWales41British ChampionshipGlasgowScotland
0
491886-11-25United StatesCanada32FriendlyNewarkUnited States
0
501887-02-05EnglandNorthern Ireland70British ChampionshipSheffieldEngland
0
511887-02-19ScotlandNorthern Ireland41British ChampionshipGlasgowScotland
0
521887-02-26EnglandWales40British ChampionshipLondonEngland
0
531887-03-12Northern IrelandWales41British ChampionshipBelfastRepublic of Ireland
0
541887-03-19EnglandScotland23British ChampionshipBlackburnEngland
0
551887-03-21WalesScotland02British ChampionshipWrexhamWales
0
561888-02-04EnglandWales51British ChampionshipCreweEngland
0
571888-03-03WalesNorthern Ireland110British ChampionshipWrexhamWales
0
581888-03-10ScotlandWales51British ChampionshipEdinburghScotland
0
591888-03-17ScotlandEngland05British ChampionshipGlasgowScotland
0
601888-03-24Northern IrelandScotland210British ChampionshipBelfastRepublic of Ireland
0
611888-04-07Northern IrelandEngland15British ChampionshipBelfastRepublic of Ireland
0
621888-09-19ScotlandCanada40FriendlyGlasgowScotland
0
631889-02-23EnglandWales41British ChampionshipStoke-on-TrentEngland
0
641889-03-02EnglandNorthern Ireland61British ChampionshipLiverpoolEngland
0
651889-03-09ScotlandNorthern Ireland70British ChampionshipGlasgowScotland
0
661889-04-13EnglandScotland23British ChampionshipLondonEngland
0
671889-04-15WalesScotland00British ChampionshipWrexhamWales
0
681889-04-27Northern IrelandWales13British ChampionshipBelfastRepublic of Ireland
0
691890-02-08WalesNorthern Ireland52British ChampionshipShrewsburyEngland
0
701890-03-15Northern IrelandEngland19British ChampionshipBelfastRepublic of Ireland
0
711890-03-15WalesEngland13British ChampionshipWrexhamWales
0
721890-03-22ScotlandWales50British ChampionshipPaisleyScotland
0
731890-03-29Northern IrelandScotland14British ChampionshipBelfastRepublic of Ireland
0
741890-04-05ScotlandEngland11British ChampionshipGlasgowScotland
0
751891-02-07Northern IrelandWales72British ChampionshipBelfastRepublic of Ireland
0
761891-03-07EnglandNorthern Ireland61British ChampionshipWolverhamptonEngland
0
771891-03-07EnglandWales41British ChampionshipSunderlandEngland
0
781891-03-21WalesScotland34British ChampionshipWrexhamWales
0
791891-03-28ScotlandNorthern Ireland21British ChampionshipGlasgowScotland
0
801891-04-06EnglandScotland21British ChampionshipBlackburnEngland
0
811892-02-27WalesNorthern Ireland11British ChampionshipBangorWales
0
821892-03-05Northern IrelandEngland02British ChampionshipBelfastRepublic of Ireland
0
831892-03-05WalesEngland02British ChampionshipWrexhamWales
0
841892-03-19Northern IrelandScotland23British ChampionshipBelfastRepublic of Ireland
0
851892-03-26ScotlandWales61British ChampionshipEdinburghScotland
0
861892-04-02ScotlandEngland14British ChampionshipGlasgowScotland
0
871893-02-25EnglandNorthern Ireland61British ChampionshipBirminghamEngland
0
881893-03-13EnglandWales60British ChampionshipStoke-on-TrentEngland
0
891893-03-18WalesScotland08British ChampionshipWrexhamWales
0
901893-03-25ScotlandNorthern Ireland61British ChampionshipGlasgowScotland
0
911893-04-01EnglandScotland52British ChampionshipRichmondEngland
0
921894-02-24WalesNorthern Ireland41British ChampionshipSwanseaWales
0
931894-03-03Northern IrelandEngland22British ChampionshipBelfastRepublic of Ireland
0
941894-03-12WalesEngland15British ChampionshipWrexhamWales
0
951894-03-24ScotlandWales52British ChampionshipKilmarnockScotland
0
961894-03-31Northern IrelandScotland12British ChampionshipBelfastRepublic of Ireland
0
971894-04-07ScotlandEngland22British ChampionshipGlasgowScotland
0
981895-03-09EnglandNorthern Ireland90British ChampionshipDerbyEngland
0
991895-03-16Northern IrelandWales22British ChampionshipBelfastRepublic of Ireland
0
1001895-03-18EnglandWales11British ChampionshipLondonEngland
0
Rows: 1-100 | Columns: 10

We can aggregate the data and get each team's continent.

In [21]:
confederation = football.groupby(["home_team"],
                                 [st.max(football["confederation"])._as("confederation")])
display(confederation)
Abc
home_team
Varchar(64)
123
confederation
Integer
1Kernow0
2Martinique1
3New Zealand0
4Orkney0
5Saint Helena0
6Iran3
7South Africa4
8Sápmi0
9Morocco4
10Gozo0
11Ã…land Islands0
12Honduras2
13Panjab0
14Artsakh0
15Scotland5
16Mauritania4
17Matabeleland0
18Falkland Islands0
19Eswatini4
20Poland5
21Monaco0
22Rwanda4
23Saint Vincent and the Grenadines0
24Serbia5
25Burma3
26Tonga0
27Saudi Arabia3
28Gibraltar5
29Denmark5
30Iceland5
31Northern Ireland5
32Cape Verde4
33Montserrat0
34Gabon4
35Angola4
36Uruguay2
37Réunion0
38North Macedonia5
39Croatia5
40Chameria0
41Tahiti0
42Singapore3
43Belize0
44United Arab Emirates3
45Vatican City0
46Republic of St. Pauli0
47Găgăuzia0
48Saint Pierre and Miquelon0
49Ynys Môn0
50Parishes of Jersey0
51Togo4
52Arameans Suryoye0
53Sweden5
54Crimea0
55South Sudan4
56Northern Cyprus0
57Brittany0
58Madagascar4
59Vanuatu0
60São Tomé and Príncipe4
61Italy5
62Papua New Guinea0
63Curaçao1
64Botswana4
65French Guiana1
66Székely Land0
67Padania0
68Macau3
69Kosovo5
70Liberia4
71Sudan4
72Nepal3
73Iraqi Kurdistan0
74Isle of Wight0
75Gambia4
76Lesotho4
77Hitra0
78Bahamas0
79Romania5
80United Koreans in Japan0
81Central African Republic4
82Malaysia3
83Tanzania4
84Estonia5
85Aruba0
86Guinea4
87Ellan Vannin0
88Yorkshire0
89Zambia4
90Chad4
91Uzbekistan3
92Turkey5
93Solomon Islands0
94Australia3
95India3
96Somaliland0
97Cyprus5
98Micronesia0
99Saarland0
100Russia5
Rows: 1-100 | Columns: 2

We can decode the previous label encoding.

In [22]:
confederation["confederation"].decode(5, "UEFA",
                                      4, "CAF",
                                      3, "AFC",
                                      2, "CONMEBOL",
                                      1, "CONCACAF",
                                      "OFC")
Out[22]:
Abc
home_team
Varchar(64)
Abc
confederation
Varchar(8)
1KernowOFC
2MartiniqueCONCACAF
3New ZealandOFC
4OrkneyOFC
5Saint HelenaOFC
6IranAFC
7South AfricaCAF
8SápmiOFC
9MoroccoCAF
10GozoOFC
11Ã…land IslandsOFC
12HondurasCONMEBOL
13PanjabOFC
14ArtsakhOFC
15ScotlandUEFA
16MauritaniaCAF
17MatabelelandOFC
18Falkland IslandsOFC
19EswatiniCAF
20PolandUEFA
21MonacoOFC
22RwandaCAF
23Saint Vincent and the GrenadinesOFC
24SerbiaUEFA
25BurmaAFC
26TongaOFC
27Saudi ArabiaAFC
28GibraltarUEFA
29DenmarkUEFA
30IcelandUEFA
31Northern IrelandUEFA
32Cape VerdeCAF
33MontserratOFC
34GabonCAF
35AngolaCAF
36UruguayCONMEBOL
37RéunionOFC
38North MacedoniaUEFA
39CroatiaUEFA
40ChameriaOFC
41TahitiOFC
42SingaporeAFC
43BelizeOFC
44United Arab EmiratesAFC
45Vatican CityOFC
46Republic of St. PauliOFC
47GăgăuziaOFC
48Saint Pierre and MiquelonOFC
49Ynys MônOFC
50Parishes of JerseyOFC
51TogoCAF
52Arameans SuryoyeOFC
53SwedenUEFA
54CrimeaOFC
55South SudanCAF
56Northern CyprusOFC
57BrittanyOFC
58MadagascarCAF
59VanuatuOFC
60São Tomé and PríncipeCAF
61ItalyUEFA
62Papua New GuineaOFC
63CuraçaoCONCACAF
64BotswanaCAF
65French GuianaCONCACAF
66Székely LandOFC
67PadaniaOFC
68MacauAFC
69KosovoUEFA
70LiberiaCAF
71SudanCAF
72NepalAFC
73Iraqi KurdistanOFC
74Isle of WightOFC
75GambiaCAF
76LesothoCAF
77HitraOFC
78BahamasOFC
79RomaniaUEFA
80United Koreans in JapanOFC
81Central African RepublicCAF
82MalaysiaAFC
83TanzaniaCAF
84EstoniaUEFA
85ArubaOFC
86GuineaCAF
87Ellan VanninOFC
88YorkshireOFC
89ZambiaCAF
90ChadCAF
91UzbekistanAFC
92TurkeyUEFA
93Solomon IslandsOFC
94AustraliaAFC
95IndiaAFC
96SomalilandOFC
97CyprusUEFA
98MicronesiaOFC
99SaarlandOFC
100RussiaUEFA
Rows: 1-100 | Columns: 2

Let's export the result to our Vertica database.

In [23]:
vp.drop("confederation")
confederation["home_team"].rename("team")
confederation.to_db(name = "confederation",
                    relation_type = "table")
Out[23]:
Abc
confederation
Varchar(8)
Abc
team
Varchar(64)
1OFCKernow
2CONCACAFMartinique
3OFCNew Zealand
4OFCOrkney
5OFCSaint Helena
6AFCIran
7CAFSouth Africa
8OFCSápmi
9CAFMorocco
10OFCGozo
11OFCÃ…land Islands
12CONMEBOLHonduras
13OFCPanjab
14OFCArtsakh
15UEFAScotland
16CAFMauritania
17OFCMatabeleland
18OFCFalkland Islands
19CAFEswatini
20UEFAPoland
21OFCMonaco
22CAFRwanda
23OFCSaint Vincent and the Grenadines
24UEFASerbia
25AFCBurma
26OFCTonga
27AFCSaudi Arabia
28UEFAGibraltar
29UEFADenmark
30UEFAIceland
31UEFANorthern Ireland
32CAFCape Verde
33OFCMontserrat
34CAFGabon
35CAFAngola
36CONMEBOLUruguay
37OFCRéunion
38UEFANorth Macedonia
39UEFACroatia
40OFCChameria
41OFCTahiti
42AFCSingapore
43OFCBelize
44AFCUnited Arab Emirates
45OFCVatican City
46OFCRepublic of St. Pauli
47OFCGăgăuzia
48OFCSaint Pierre and Miquelon
49OFCYnys Môn
50OFCParishes of Jersey
51CAFTogo
52OFCArameans Suryoye
53UEFASweden
54OFCCrimea
55CAFSouth Sudan
56OFCNorthern Cyprus
57OFCBrittany
58CAFMadagascar
59OFCVanuatu
60CAFSão Tomé and Príncipe
61UEFAItaly
62OFCPapua New Guinea
63CONCACAFCuraçao
64CAFBotswana
65CONCACAFFrench Guiana
66OFCSzékely Land
67OFCPadania
68AFCMacau
69UEFAKosovo
70CAFLiberia
71CAFSudan
72AFCNepal
73OFCIraqi Kurdistan
74OFCIsle of Wight
75CAFGambia
76CAFLesotho
77OFCHitra
78OFCBahamas
79UEFARomania
80OFCUnited Koreans in Japan
81CAFCentral African Republic
82AFCMalaysia
83CAFTanzania
84UEFAEstonia
85OFCAruba
86CAFGuinea
87OFCEllan Vannin
88OFCYorkshire
89CAFZambia
90CAFChad
91AFCUzbekistan
92UEFATurkey
93OFCSolomon Islands
94AFCAustralia
95AFCIndia
96OFCSomaliland
97UEFACyprus
98OFCMicronesia
99OFCSaarland
100UEFARussia
Rows: 1-100 | Columns: 2

Team KPIs

We use just two variables to track teams: away_team and home_team. This makes it a bit difficult to compute new features. We need to duplicate the dataset and intervert the two teams. This way, we can compute KPIs using a partition by the first team to avoid double-counting any games.

In [24]:
football = vp.vDataFrame("football_clean")
football.filter(st.year(football["date"]) <= 2015)
football["home_team"].rename("team1")
football["home_score"].rename("team1_score")
football["away_team"].rename("team2")
football["away_score"].rename("team2_score")
football["neutral"].decode(True, 0, 1)

football2 = vp.vDataFrame("football_clean")
football2.filter(st.year(football["date"]) <= 2015)
football2["home_team"].rename("team2")
football2["home_score"].rename("team2_score")
football2["away_team"].rename("team1")
football2["away_score"].rename("team1_score")
football2["neutral"].decode(True, 0, 2)


# Merging the 2 interverted datasets
all_matchs = football.append(football2)
all_matchs["neutral"].rename("home_team_id")
3884 elements were filtered
3884 elements were filtered
Out[24]:
📅
date
Date
Abc
tournament
Varchar(84)
Abc
country
Varchar(64)
Abc
city
Varchar(56)
Abc
team1
Varchar(64)
123
team1_score
Integer
Abc
team2
Varchar(64)
123
team2_score
Integer
123
home_team_id
Integer
11872-11-30FriendlyScotlandGlasgowScotland0England01
21873-03-08FriendlyEnglandLondonEngland4Scotland21
31874-03-07FriendlyScotlandGlasgowScotland2England11
41875-03-06FriendlyEnglandLondonEngland2Scotland21
51876-03-04FriendlyScotlandGlasgowScotland3England01
61876-03-25FriendlyScotlandGlasgowScotland4Wales01
71877-03-03FriendlyEnglandLondonEngland1Scotland31
81877-03-05FriendlyWalesWrexhamWales0Scotland21
91878-03-02FriendlyScotlandGlasgowScotland7England21
101878-03-23FriendlyScotlandGlasgowScotland9Wales01
111879-01-18FriendlyEnglandLondonEngland2Wales11
121879-04-05FriendlyEnglandLondonEngland5Scotland41
131879-04-07FriendlyWalesWrexhamWales0Scotland31
141880-03-13FriendlyScotlandGlasgowScotland5England41
151880-03-15FriendlyWalesWrexhamWales2England31
161880-03-27FriendlyScotlandGlasgowScotland5Wales11
171881-02-26FriendlyEnglandBlackburnEngland0Wales11
181881-03-12FriendlyEnglandLondonEngland1Scotland61
191881-03-14FriendlyWalesWrexhamWales1Scotland51
201882-02-18FriendlyRepublic of IrelandBelfastNorthern Ireland0England131
211882-02-25FriendlyWalesWrexhamWales7Northern Ireland11
221882-03-11FriendlyScotlandGlasgowScotland5England11
231882-03-13FriendlyWalesWrexhamWales5England31
241882-03-25FriendlyScotlandGlasgowScotland5Wales01
251883-02-03FriendlyEnglandLondonEngland5Wales01
261883-02-24FriendlyEnglandLiverpoolEngland7Northern Ireland01
271883-03-10FriendlyEnglandSheffieldEngland2Scotland31
281883-03-12FriendlyWalesWrexhamWales0Scotland31
291883-03-17FriendlyRepublic of IrelandBelfastNorthern Ireland1Wales11
301884-01-26British ChampionshipRepublic of IrelandBelfastNorthern Ireland0Scotland51
311884-02-09British ChampionshipWalesWrexhamWales6Northern Ireland01
321884-02-23British ChampionshipRepublic of IrelandBelfastNorthern Ireland1England81
331884-03-15British ChampionshipScotlandGlasgowScotland1England01
341884-03-17British ChampionshipWalesWrexhamWales0England41
351884-03-29British ChampionshipScotlandGlasgowScotland4Wales11
361885-02-28British ChampionshipEnglandManchesterEngland4Northern Ireland01
371885-03-14British ChampionshipEnglandBlackburnEngland1Wales11
381885-03-14British ChampionshipScotlandGlasgowScotland8Northern Ireland21
391885-03-21British ChampionshipEnglandLondonEngland1Scotland11
401885-03-23British ChampionshipWalesWrexhamWales1Scotland81
411885-04-11British ChampionshipRepublic of IrelandBelfastNorthern Ireland2Wales81
421885-11-28FriendlyUnited StatesNewarkUnited States0Canada11
431886-02-27British ChampionshipWalesWrexhamWales5Northern Ireland01
441886-03-13British ChampionshipRepublic of IrelandBelfastNorthern Ireland1England61
451886-03-20British ChampionshipRepublic of IrelandBelfastNorthern Ireland2Scotland71
461886-03-27British ChampionshipScotlandGlasgowScotland1England11
471886-03-29British ChampionshipWalesWrexhamWales1England31
481886-04-10British ChampionshipScotlandGlasgowScotland4Wales11
491886-11-25FriendlyUnited StatesNewarkUnited States3Canada21
501887-02-05British ChampionshipEnglandSheffieldEngland7Northern Ireland01
511887-02-19British ChampionshipScotlandGlasgowScotland4Northern Ireland11
521887-02-26British ChampionshipEnglandLondonEngland4Wales01
531887-03-12British ChampionshipRepublic of IrelandBelfastNorthern Ireland4Wales11
541887-03-19British ChampionshipEnglandBlackburnEngland2Scotland31
551887-03-21British ChampionshipWalesWrexhamWales0Scotland21
561888-02-04British ChampionshipEnglandCreweEngland5Wales11
571888-03-03British ChampionshipWalesWrexhamWales11Northern Ireland01
581888-03-10British ChampionshipScotlandEdinburghScotland5Wales11
591888-03-17British ChampionshipScotlandGlasgowScotland0England51
601888-03-24British ChampionshipRepublic of IrelandBelfastNorthern Ireland2Scotland101
611888-04-07British ChampionshipRepublic of IrelandBelfastNorthern Ireland1England51
621888-09-19FriendlyScotlandGlasgowScotland4Canada01
631889-02-23British ChampionshipEnglandStoke-on-TrentEngland4Wales11
641889-03-02British ChampionshipEnglandLiverpoolEngland6Northern Ireland11
651889-03-09British ChampionshipScotlandGlasgowScotland7Northern Ireland01
661889-04-13British ChampionshipEnglandLondonEngland2Scotland31
671889-04-15British ChampionshipWalesWrexhamWales0Scotland01
681889-04-27British ChampionshipRepublic of IrelandBelfastNorthern Ireland1Wales31
691890-02-08British ChampionshipEnglandShrewsburyWales5Northern Ireland20
701890-03-15British ChampionshipRepublic of IrelandBelfastNorthern Ireland1England91
711890-03-15British ChampionshipWalesWrexhamWales1England31
721890-03-22British ChampionshipScotlandPaisleyScotland5Wales01
731890-03-29British ChampionshipRepublic of IrelandBelfastNorthern Ireland1Scotland41
741890-04-05British ChampionshipScotlandGlasgowScotland1England11
751891-02-07British ChampionshipRepublic of IrelandBelfastNorthern Ireland7Wales21
761891-03-07British ChampionshipEnglandSunderlandEngland4Wales11
771891-03-07British ChampionshipEnglandWolverhamptonEngland6Northern Ireland11
781891-03-21British ChampionshipWalesWrexhamWales3Scotland41
791891-03-28British ChampionshipScotlandGlasgowScotland2Northern Ireland11
801891-04-06British ChampionshipEnglandBlackburnEngland2Scotland11
811892-02-27British ChampionshipWalesBangorWales1Northern Ireland11
821892-03-05British ChampionshipRepublic of IrelandBelfastNorthern Ireland0England21
831892-03-05British ChampionshipWalesWrexhamWales0England21
841892-03-19British ChampionshipRepublic of IrelandBelfastNorthern Ireland2Scotland31
851892-03-26British ChampionshipScotlandEdinburghScotland6Wales11
861892-04-02British ChampionshipScotlandGlasgowScotland1England41
871893-02-25British ChampionshipEnglandBirminghamEngland6Northern Ireland11
881893-03-13British ChampionshipEnglandStoke-on-TrentEngland6Wales01
891893-03-18British ChampionshipWalesWrexhamWales0Scotland81
901893-03-25British ChampionshipScotlandGlasgowScotland6Northern Ireland11
911893-04-01British ChampionshipEnglandRichmondEngland5Scotland21
921894-02-24British ChampionshipWalesSwanseaWales4Northern Ireland11
931894-03-03British ChampionshipRepublic of IrelandBelfastNorthern Ireland2England21
941894-03-12British ChampionshipWalesWrexhamWales1England51
951894-03-24British ChampionshipScotlandKilmarnockScotland5Wales21
961894-03-31British ChampionshipRepublic of IrelandBelfastNorthern Ireland1Scotland21
971894-04-07British ChampionshipScotlandGlasgowScotland2England21
981895-03-09British ChampionshipEnglandDerbyEngland9Northern Ireland01
991895-03-16British ChampionshipRepublic of IrelandBelfastNorthern Ireland2Wales21
1001895-03-18British ChampionshipEnglandLondonEngland1Wales11
Rows: 1-100 | Columns: 9

To compute the different aggregations, we need to add dummies which indicate the type of game and winner.

In [25]:
all_matchs["World_Tournament"] = st.case_when(all_matchs["tournament"]._in(["FIFA World Cup",
                                                                            "Confederations Cup"]), 1, 0)
all_matchs["Continental_Tournament"] = st.case_when(all_matchs["tournament"]._in([
                                                                            "UEFA Euro", 
                                                                            "Copa América", 
                                                                            "African Cup of Nations",
                                                                            "AFC Asian Cup",
                                                                            "Gold Cup",
                                                                            "FIFA World Cup qualification"]), 1, 0)
all_matchs["Victory_team1"] = (all_matchs["team1_score"] > all_matchs["team2_score"])
all_matchs["Victory_team1"].astype("int")
all_matchs["Draw"] = (all_matchs["team1_score"] == all_matchs["team2_score"])
all_matchs["Draw"].astype("int")
Out[25]:
📅
date
Date
Abc
tournament
Varchar(84)
Abc
country
Varchar(64)
Abc
city
Varchar(56)
Abc
team1
Varchar(64)
123
team1_score
Integer
Abc
team2
Varchar(64)
123
team2_score
Integer
123
home_team_id
Integer
123
World_Tournament
Integer
123
Continental_Tournament
Integer
123
Victory_team1
Int
123
Draw
Int
11872-11-30FriendlyScotlandGlasgowScotland0England010001
21873-03-08FriendlyEnglandLondonEngland4Scotland210010
31874-03-07FriendlyScotlandGlasgowScotland2England110010
41875-03-06FriendlyEnglandLondonEngland2Scotland210001
51876-03-04FriendlyScotlandGlasgowScotland3England010010
61876-03-25FriendlyScotlandGlasgowScotland4Wales010010
71877-03-03FriendlyEnglandLondonEngland1Scotland310000
81877-03-05FriendlyWalesWrexhamWales0Scotland210000
91878-03-02FriendlyScotlandGlasgowScotland7England210010
101878-03-23FriendlyScotlandGlasgowScotland9Wales010010
111879-01-18FriendlyEnglandLondonEngland2Wales110010
121879-04-05FriendlyEnglandLondonEngland5Scotland410010
131879-04-07FriendlyWalesWrexhamWales0Scotland310000
141880-03-13FriendlyScotlandGlasgowScotland5England410010
151880-03-15FriendlyWalesWrexhamWales2England310000
161880-03-27FriendlyScotlandGlasgowScotland5Wales110010
171881-02-26FriendlyEnglandBlackburnEngland0Wales110000
181881-03-12FriendlyEnglandLondonEngland1Scotland610000
191881-03-14FriendlyWalesWrexhamWales1Scotland510000
201882-02-18FriendlyRepublic of IrelandBelfastNorthern Ireland0England1310000
211882-02-25FriendlyWalesWrexhamWales7Northern Ireland110010
221882-03-11FriendlyScotlandGlasgowScotland5England110010
231882-03-13FriendlyWalesWrexhamWales5England310010
241882-03-25FriendlyScotlandGlasgowScotland5Wales010010
251883-02-03FriendlyEnglandLondonEngland5Wales010010
261883-02-24FriendlyEnglandLiverpoolEngland7Northern Ireland010010
271883-03-10FriendlyEnglandSheffieldEngland2Scotland310000
281883-03-12FriendlyWalesWrexhamWales0Scotland310000
291883-03-17FriendlyRepublic of IrelandBelfastNorthern Ireland1Wales110001
301884-01-26British ChampionshipRepublic of IrelandBelfastNorthern Ireland0Scotland510000
311884-02-09British ChampionshipWalesWrexhamWales6Northern Ireland010010
321884-02-23British ChampionshipRepublic of IrelandBelfastNorthern Ireland1England810000
331884-03-15British ChampionshipScotlandGlasgowScotland1England010010
341884-03-17British ChampionshipWalesWrexhamWales0England410000
351884-03-29British ChampionshipScotlandGlasgowScotland4Wales110010
361885-02-28British ChampionshipEnglandManchesterEngland4Northern Ireland010010
371885-03-14British ChampionshipEnglandBlackburnEngland1Wales110001
381885-03-14British ChampionshipScotlandGlasgowScotland8Northern Ireland210010
391885-03-21British ChampionshipEnglandLondonEngland1Scotland110001
401885-03-23British ChampionshipWalesWrexhamWales1Scotland810000
411885-04-11British ChampionshipRepublic of IrelandBelfastNorthern Ireland2Wales810000
421885-11-28FriendlyUnited StatesNewarkUnited States0Canada110000
431886-02-27British ChampionshipWalesWrexhamWales5Northern Ireland010010
441886-03-13British ChampionshipRepublic of IrelandBelfastNorthern Ireland1England610000
451886-03-20British ChampionshipRepublic of IrelandBelfastNorthern Ireland2Scotland710000
461886-03-27British ChampionshipScotlandGlasgowScotland1England110001
471886-03-29British ChampionshipWalesWrexhamWales1England310000
481886-04-10British ChampionshipScotlandGlasgowScotland4Wales110010
491886-11-25FriendlyUnited StatesNewarkUnited States3Canada210010
501887-02-05British ChampionshipEnglandSheffieldEngland7Northern Ireland010010
511887-02-19British ChampionshipScotlandGlasgowScotland4Northern Ireland110010
521887-02-26British ChampionshipEnglandLondonEngland4Wales010010
531887-03-12British ChampionshipRepublic of IrelandBelfastNorthern Ireland4Wales110010
541887-03-19British ChampionshipEnglandBlackburnEngland2Scotland310000
551887-03-21British ChampionshipWalesWrexhamWales0Scotland210000
561888-02-04British ChampionshipEnglandCreweEngland5Wales110010
571888-03-03British ChampionshipWalesWrexhamWales11Northern Ireland010010
581888-03-10British ChampionshipScotlandEdinburghScotland5Wales110010
591888-03-17British ChampionshipScotlandGlasgowScotland0England510000
601888-03-24British ChampionshipRepublic of IrelandBelfastNorthern Ireland2Scotland1010000
611888-04-07British ChampionshipRepublic of IrelandBelfastNorthern Ireland1England510000
621888-09-19FriendlyScotlandGlasgowScotland4Canada010010
631889-02-23British ChampionshipEnglandStoke-on-TrentEngland4Wales110010
641889-03-02British ChampionshipEnglandLiverpoolEngland6Northern Ireland110010
651889-03-09British ChampionshipScotlandGlasgowScotland7Northern Ireland010010
661889-04-13British ChampionshipEnglandLondonEngland2Scotland310000
671889-04-15British ChampionshipWalesWrexhamWales0Scotland010001
681889-04-27British ChampionshipRepublic of IrelandBelfastNorthern Ireland1Wales310000
691890-02-08British ChampionshipEnglandShrewsburyWales5Northern Ireland200010
701890-03-15British ChampionshipRepublic of IrelandBelfastNorthern Ireland1England910000
711890-03-15British ChampionshipWalesWrexhamWales1England310000
721890-03-22British ChampionshipScotlandPaisleyScotland5Wales010010
731890-03-29British ChampionshipRepublic of IrelandBelfastNorthern Ireland1Scotland410000
741890-04-05British ChampionshipScotlandGlasgowScotland1England110001
751891-02-07British ChampionshipRepublic of IrelandBelfastNorthern Ireland7Wales210010
761891-03-07British ChampionshipEnglandSunderlandEngland4Wales110010
771891-03-07British ChampionshipEnglandWolverhamptonEngland6Northern Ireland110010
781891-03-21British ChampionshipWalesWrexhamWales3Scotland410000
791891-03-28British ChampionshipScotlandGlasgowScotland2Northern Ireland110010
801891-04-06British ChampionshipEnglandBlackburnEngland2Scotland110010
811892-02-27British ChampionshipWalesBangorWales1Northern Ireland110001
821892-03-05British ChampionshipRepublic of IrelandBelfastNorthern Ireland0England210000
831892-03-05British ChampionshipWalesWrexhamWales0England210000
841892-03-19British ChampionshipRepublic of IrelandBelfastNorthern Ireland2Scotland310000
851892-03-26British ChampionshipScotlandEdinburghScotland6Wales110010
861892-04-02British ChampionshipScotlandGlasgowScotland1England410000
871893-02-25British ChampionshipEnglandBirminghamEngland6Northern Ireland110010
881893-03-13British ChampionshipEnglandStoke-on-TrentEngland6Wales010010
891893-03-18British ChampionshipWalesWrexhamWales0Scotland810000
901893-03-25British ChampionshipScotlandGlasgowScotland6Northern Ireland110010
911893-04-01British ChampionshipEnglandRichmondEngland5Scotland210010
921894-02-24British ChampionshipWalesSwanseaWales4Northern Ireland110010
931894-03-03British ChampionshipRepublic of IrelandBelfastNorthern Ireland2England210001
941894-03-12British ChampionshipWalesWrexhamWales1England510000
951894-03-24British ChampionshipScotlandKilmarnockScotland5Wales210010
961894-03-31British ChampionshipRepublic of IrelandBelfastNorthern Ireland1Scotland210000
971894-04-07British ChampionshipScotlandGlasgowScotland2England210001
981895-03-09British ChampionshipEnglandDerbyEngland9Northern Ireland010010
991895-03-16British ChampionshipRepublic of IrelandBelfastNorthern Ireland2Wales210001
1001895-03-18British ChampionshipEnglandLondonEngland1Wales110001
Rows: 1-100 | Columns: 13

Now we can compute each team's KPI.

In [26]:
teams_kpi = all_matchs.groupby(["team1"],
   [st.sum(all_matchs["World_Tournament"])._as("Number_Games_World_Tournament"),
    st.sum(all_matchs["Continental_Tournament"])._as("Number_Games_Continental_Tournament"),
    st.avg(st.decode(all_matchs["World_Tournament"], 
                     1, all_matchs["Victory_team1"]))._as("Percent_Victory_World_Tournament"),
    st.avg(st.decode(all_matchs["Continental_Tournament"], 
                     1, all_matchs["Victory_team1"]))._as("Percent_Victory_Continental_Tournament"),
    st.avg(st.case_when((all_matchs["home_team_id"] == 1) & 
                        (all_matchs["World_Tournament"] == 0) &
                        (all_matchs["Continental_Tournament"] == 0), 
                        all_matchs["Victory_team1"], None))._as("Percent_Victory_Home"),
    st.avg(st.case_when((all_matchs["home_team_id"] != 1) & 
                        (all_matchs["World_Tournament"] == 0) &
                        (all_matchs["Continental_Tournament"] == 0), 
                        all_matchs["Victory_team1"], None))._as("Percent_Victory_Away"),
    st.avg(all_matchs["Victory_team1"])._as("Percent_Victory"),
    st.avg(all_matchs["Draw"])._as("Percent_Draw"),
    st.avg(all_matchs["team1_score"])._as("Avg_goals"),
    st.avg(all_matchs["team2_score"])._as("Avg_goals_conceded")]).sort({"Number_Games_World_Tournament": "desc"})
display(teams_kpi)
Abc
team1
Varchar(64)
123
Number_Games_World_Tournament
Integer
123
Integer
123
Percent_Victory_World_Tournament
Float
123
Float
123
Percent_Victory_Home
Float
123
Percent_Victory_Away
Float
123
Percent_Victory
Float
123
Percent_Draw
Float
123
Avg_goals
Float
123
Avg_goals_conceded
Float
1Brazil1370.6788321167883210.7333333333333330.593750.6350914962325080.200215285252962.193756727664160.93756727664155
2Germany1200.60.6083916083916080.4702127659574470.5553691275167780.2080536912751682.09983221476511.17953020134228
3Italy910.5274725274725270.6438848920863310.3464566929133860.5245683930942890.2828685258964141.695883134130150.98273572377158
4Argentina870.5402298850574710.6380952380952380.4060606060606060.5360602798708290.2486544671689991.865446716899891.05059203444564
5Mexico750.3066666666666670.5424836601307190.4235668789808920.4950.23751.74751.07625
6Spain690.5217391304347830.6768558951965070.4656862745098040.5813953488372090.2248062015503881.967441860465120.908527131782946
7France690.5362318840579710.5321100917431190.3636363636363640.4808184143222510.2148337595907931.758312020460361.34271099744246
8England620.4193548387096770.618784530386740.5308641975308640.5657620041753650.2411273486430062.199373695198330.992693110647182
9Uruguay610.4098360655737710.50.3007246376811590.4302741358760430.2455303933253871.575685339690111.26460071513707
10Netherlands500.540.5422535211267610.3852140077821010.5033738191632930.2280701754385962.062078272604591.24966261808367
11United States480.2916666666666670.4065420560747660.2620689655172410.4196141479099680.2122186495176851.419614147909971.37138263665595
12Sweden460.3478260869565220.5805555555555560.4109263657957240.4942886812045690.2170301142263762.005192107995851.30633437175493
13Serbia430.3953488372093020.5445026178010470.381502890173410.4564606741573030.2191011235955061.816011235955061.37921348314607
14Belgium410.3414634146341460.4785714285714290.2846153846153850.4106145251396650.219273743016761.684357541899441.60614525139665
15Russia400.4250.5932203389830510.4561403508771930.5216718266253870.2647058823529411.719814241486070.93343653250774
16Czech Republic380.3684210526315790.6543209876543210.341853035143770.4833110814419230.2216288384512681.84379172229641.23497997329773
17South Korea340.2058823529411760.5789473684210530.5122615803814710.5286783042394020.2568578553615961.783042394014960.897755610972569
18Chile330.3333333333333330.5582822085889570.2571428571428570.380480905233380.2065063649222071.421499292786421.46534653465347
19Switzerland330.3333333333333330.4133333333333330.2275862068965520.3390957446808510.2167553191489361.441489361702131.7313829787234
20Japan330.2727272727272730.5263157894736840.4009433962264150.4718309859154930.2341549295774651.720070422535211.16021126760563
21Hungary320.468750.5809248554913290.3822784810126580.4740990990990990.2195945945945952.072072072072071.4954954954955
22Poland310.4838709677419350.50.3521126760563380.4259740259740260.2519480519480521.684415584415581.37012987012987
23Cameroon310.2580645161290320.5882352941176470.3205741626794260.442588726513570.300626304801671.421711899791231.05427974947808
24Austria290.4137931034482760.4837662337662340.3063380281690140.411126187245590.2198100407055631.797829036635011.59294436906377
25Paraguay270.2592592592592590.4423076923076920.2909836065573770.3637702503681880.2621502209131081.335787923416791.43888070692194
26Portugal260.50.5445026178010470.3461538461538460.4712230215827340.230215827338131.631294964028781.20143884892086
27Australia260.2692307692307690.4393939393939390.511235955056180.4989429175475690.2114164904862582.031712473572941.11205073995772
28Bulgaria260.1153846153846150.4810810810810810.2927631578947370.372456964006260.2519561815336461.431924882629111.47104851330203
29Saudi Arabia250.20.560439560439560.4170616113744080.4832451499118170.2275132275132281.596119929453261.04585537918871
30Nigeria240.2916666666666670.620370370370370.3190476190476190.4580152671755730.2958015267175571.496183206106871.00381679389313
31Colombia230.3913043478260870.468750.3571428571428570.3780.2721.2061.21
32Scotland230.1739130434782610.584775086505190.3942307692307690.4765100671140940.217449664429531.75033557046981.2255033557047
33Romania210.3809523809523810.5922330097087380.3118644067796610.4401840490797550.2561349693251531.645705521472391.28834355828221
34Denmark190.5263157894736840.5525423728813560.3466666666666670.446071904127830.2037283621837551.777629826897471.42876165113182
35South Africa170.1764705882352940.527559055118110.3709677419354840.4447592067988670.2747875354107651.33994334277621.00849858356941
36Croatia160.43750.6705882352941180.4257425742574260.5338345864661650.2706766917293231.751879699248120.981203007518797
37Turkey150.4666666666666670.453987730061350.3380281690140850.3819577735124760.2380038387715931.33205374280231.42802303262956
38Peru150.2666666666666670.4285714285714290.223602484472050.3129370629370630.2430069930069931.229020979020981.46853146853147
39Tunisia150.1333333333333330.5315789473684210.2777777777777780.4166666666666670.2916666666666671.433712121212121.06439393939394
40Costa Rica150.3333333333333330.6238532110091740.3317307692307690.4298724954462660.2568306010928961.670309653916211.16757741347905
41New Zealand150.00.4868421052631580.3468208092485550.4047619047619050.1815476190476191.747023809523811.61309523809524
42Morocco130.1538461538461540.6122448979591840.3548387096774190.4516806722689080.3004201680672271.388655462184870.873949579831933
43Algeria130.2307692307692310.5806451612903230.316384180790960.4152173913043480.2804347826086961.354347826086961.0304347826087
44Northern Ireland130.2307692307692310.2901785714285710.1721311475409840.2437810945273630.2321724709784411.043117744610281.95356550580431
45Greece130.1538461538461540.4590163934426230.2626262626262630.3650190114068440.2528517110266161.239543726235741.42015209125475
46Republic of Ireland130.1538461538461540.4875621890547260.3103448275862070.3919694072657740.2772466539196941.401529636711281.24665391969407
47Iran120.08333333333333330.6415094339622640.4303797468354430.5343680709534370.2616407982261641.840354767184040.835920177383592
48Ghana120.3333333333333330.6727272727272730.3840579710144930.482206405693950.2562277580071171.64234875444841.04092526690391
49Ivory Coast110.2727272727272730.6917293233082710.40.5029469548133590.249508840864441.634577603143421.05304518664047
50Ecuador100.40.593750.240259740259740.2944915254237290.2457627118644071.194915254237291.65042372881356
51Egypt100.10.5823529411764710.3739130434782610.4863013698630140.251.643835616438361.03595890410959
52Honduras90.00.5483870967741940.331606217616580.4085106382978720.2617021276595741.491489361702131.22340425531915
53Bolivia90.00.3787878787878790.1386138613861390.2219570405727920.2482100238663481.03818615751791.94272076372315
54Norway80.250.3948220064724920.3343465045592710.3599476439790580.2277486910994761.501308900523561.68455497382199
55North Korea70.1428571428571430.7333333333333330.4088397790055250.4266666666666670.271.611.03666666666667
56Canada60.00.3387096774193550.2814814814814810.3314121037463980.2391930835734871.048991354466861.39769452449568
57El Salvador60.00.4819277108433730.2009132420091320.3211206896551720.2262931034482761.226293103448281.48706896551724
58United Arab Emirates60.1666666666666670.476821192052980.3368421052631580.3957446808510640.2489361702127661.414893617021281.28510638297872
59Iraq60.00.6666666666666670.4362416107382550.4676113360323890.2773279352226721.621457489878540.945344129554656
60Slovenia60.1666666666666670.4264705882352940.2857142857142860.3521126760563380.2347417840375591.239436619718311.27230046948357
61Wales50.20.3670886075949370.2651515151515150.3100649350649350.2126623376623381.253246753246751.69318181818182
62Ukraine50.40.5285714285714290.3370786516853930.4405286343612330.2907488986784141.396475770925110.973568281938326
63Senegal50.40.6480.3360655737704920.4229166666666670.268751.28751.00208333333333
64Slovakia40.250.450.3333333333333330.4016064257028110.2369477911646591.441767068273091.30120481927711
65Israel30.00.3892617449664430.303278688524590.3492462311557790.2512562814070351.454773869346731.45226130653266
66DR Congo30.00.6153846153846150.3081081081081080.3913043478260870.2681159420289861.50241545893721.2536231884058
67Tahiti30.00.4838709677419350.5846153846153850.5183246073298430.125654450261782.518324607329841.70157068062827
68Bosnia and Herzegovina30.3333333333333330.4285714285714290.3048780487804880.3846153846153850.2142857142857141.428571428571431.39010989010989
69Haiti30.00.5304347826086960.3585858585858590.4138755980861240.2320574162679431.56220095693781.31818181818182
70Trinidad and Tobago30.00.6224489795918370.3763440860215050.4526484751203850.2102728731942211.739967897271271.27447833065811
71Cuba30.3333333333333330.450.3728813559322030.3461538461538460.251.320512820512821.43910256410256
72Angola30.00.56250.2535211267605630.3527508090614890.3527508090614891.17475728155341.042071197411
73China PR30.00.5796178343949040.3958333333333330.4881170018281540.2266910420475321.837294332723951.08775137111517
74Jamaica30.3333333333333330.5304878048780490.3097345132743360.3877159309021110.2284069097888681.318618042226491.33781190019194
75Togo30.00.4845360824742270.2363636363636360.3142857142857140.2457142857142861.082857142857141.39142857142857
76Kuwait30.00.4573170731707320.3791666666666670.4240740740740740.2722222222222221.555555555555561.07962962962963
77Indonesia10.00.4926470588235290.3590604026845640.3771760154738880.1876208897485491.673114119922631.67504835589942
78Northern Mariana Islands0[null]0.00.1333333333333330.1111111111111110.05555555555555560.8888888888888894.16666666666667
79Ellan Vannin0[null][null]0.00.00.6666666666666670.6666666666666671.0
80Montserrat0[null]1.00.1052631578947370.1333333333333330.06666666666666671.033333333333334.4
81Georgia0[null]0.4909090909090910.230.2935323383084580.1890547263681591.129353233830851.48258706467662
82Lesotho0[null]0.2168674698795180.1509433962264150.1690140845070420.3098591549295770.7793427230046951.61971830985915
83Anguilla0[null]0.00.093750.06250.06250.6666666666666674.04166666666667
84Venezuela0[null]0.4705882352941180.2386363636363640.235988200589970.2064896755162240.9941002949852512.01769911504425
85Gotland0[null]0.60.2857142857142860.3461538461538460.1538461538461542.461538461538462.0
86Mongolia0[null]1.00.2413793103448280.2666666666666670.08888888888888891.088888888888893.22222222222222
87Vietnam Republic0[null]0.6153846153846150.390476190476190.4313725490196080.1764705882352941.836601307189541.73202614379085
88Curaçao0[null]0.6666666666666670.2944444444444440.3564356435643560.2673267326732671.547854785478551.67656765676568
89Jordan0[null]0.4112149532710280.2866242038216560.3479532163742690.2865497076023391.184210526315791.1140350877193
90Central African Republic0[null]0.3529411764705880.120.1688311688311690.2077922077922081.025974025974032.06493506493507
91Nepal0[null]0.3947368421052630.1463414634146340.2066666666666670.140.8133333333333332.58666666666667
92Syria0[null]0.4313725490196080.3318181818181820.3735955056179780.233146067415731.480337078651691.3314606741573
93Zanzibar0[null]0.1724137931034480.190476190476190.1878172588832490.1928934010152280.8883248730964472.16243654822335
94Raetia0[null][null]0.00.00.00.05.0
95Liechtenstein0[null]0.1481481481481480.050.07926829268292680.1219512195121950.4390243902439022.83536585365854
96Arameans Suryoye0[null][null]0.5714285714285710.5714285714285710.1428571428571431.428571428571431.14285714285714
97Tuvalu0[null][null]0.2105263157894740.2105263157894740.1052631578947371.157894736842115.31578947368421
98Tamil Eelam0[null][null]0.1666666666666670.1666666666666670.01.04.16666666666667
99Cyprus0[null]0.3014705882352940.09090909090909090.1859756097560980.1676829268292680.868902439024392.2469512195122
100Kosovo0[null]0.40.50.4285714285714290.2857142857142862.01.71428571428571
Rows: 1-100 | Columns: 11

We can join the different information about the cup winners to enrich our dataset. We'll be using this later, so let's export it to our Vertica database.

In [27]:
vp.drop("teams_kpi", relation_type = "table")
teams_kpi = teams_kpi.join(football_cup_winners,
                           on = {"team1": "winner"},
                           how = "left",
                           expr2 = ["nb_World_Cup", 
                                    "nb_Continental_Cup"]).to_db("teams_kpi", relation_type = "table")
display(teams_kpi)
Abc
team1
Varchar(64)
123
Number_Games_World_Tournament
Integer
123
Integer
123
Percent_Victory_World_Tournament
Float
123
Float
123
Percent_Victory_Home
Float
123
Percent_Victory_Away
Float
123
Percent_Victory
Float
123
Percent_Draw
Float
123
Avg_goals
Float
123
Avg_goals_conceded
Float
123
nb_World_Cup
Integer
123
nb_Continental_Cup
Integer
1Brazil1370.6788321167883210.7333333333333330.593750.6350914962325080.200215285252962.193756727664160.9375672766415548
2Germany1200.60.6083916083916080.4702127659574470.5553691275167780.2080536912751682.09983221476511.1795302013422843
3Italy910.5274725274725270.6438848920863310.3464566929133860.5245683930942890.2828685258964141.695883134130150.9827357237715831
4Argentina870.5402298850574710.6380952380952380.4060606060606060.5360602798708290.2486544671689991.865446716899891.0505920344456428
5Mexico750.3066666666666670.5424836601307190.4235668789808920.4950.23751.74751.0762506
6France690.5362318840579710.5321100917431190.3636363636363640.4808184143222510.2148337595907931.758312020460361.3427109974424612
7Spain690.5217391304347830.6768558951965070.4656862745098040.5813953488372090.2248062015503881.967441860465120.90852713178294613
8England620.4193548387096770.618784530386740.5308641975308640.5657620041753650.2411273486430062.199373695198330.99269311064718210
9Uruguay610.4098360655737710.50.3007246376811590.4302741358760430.2455303933253871.575685339690111.2646007151370728
10Netherlands500.540.5422535211267610.3852140077821010.5033738191632930.2280701754385962.062078272604591.2496626180836701
11United States480.2916666666666670.4065420560747660.2620689655172410.4196141479099680.2122186495176851.419614147909971.3713826366559502
12Sweden460.3478260869565220.5805555555555560.4109263657957240.4942886812045690.2170301142263762.005192107995851.30633437175493[null][null]
13Serbia430.3953488372093020.5445026178010470.381502890173410.4564606741573030.2191011235955061.816011235955061.37921348314607[null][null]
14Belgium410.3414634146341460.4785714285714290.2846153846153850.4106145251396650.219273743016761.684357541899441.60614525139665[null][null]
15Russia400.4250.5932203389830510.4561403508771930.5216718266253870.2647058823529411.719814241486070.9334365325077401
16Czech Republic380.3684210526315790.6543209876543210.341853035143770.4833110814419230.2216288384512681.84379172229641.23497997329773[null][null]
17South Korea340.2058823529411760.5789473684210530.5122615803814710.5286783042394020.2568578553615961.783042394014960.89775561097256903
18Chile330.3333333333333330.5582822085889570.2571428571428570.380480905233380.2065063649222071.421499292786421.4653465346534702
19Switzerland330.3333333333333330.4133333333333330.2275862068965520.3390957446808510.2167553191489361.441489361702131.7313829787234[null][null]
20Japan330.2727272727272730.5263157894736840.4009433962264150.4718309859154930.2341549295774651.720070422535211.1602112676056302
21Hungary320.468750.5809248554913290.3822784810126580.4740990990990990.2195945945945952.072072072072071.4954954954955[null][null]
22Cameroon310.2580645161290320.5882352941176470.3205741626794260.442588726513570.300626304801671.421711899791231.0542797494780802
23Poland310.4838709677419350.50.3521126760563380.4259740259740260.2519480519480521.684415584415581.37012987012987[null][null]
24Austria290.4137931034482760.4837662337662340.3063380281690140.411126187245590.2198100407055631.797829036635011.59294436906377[null][null]
25Paraguay270.2592592592592590.4423076923076920.2909836065573770.3637702503681880.2621502209131081.335787923416791.4388807069219403
26Portugal260.50.5445026178010470.3461538461538460.4712230215827340.230215827338131.631294964028781.20143884892086[null][null]
27Bulgaria260.1153846153846150.4810810810810810.2927631578947370.372456964006260.2519561815336461.431924882629111.47104851330203[null][null]
28Australia260.2692307692307690.4393939393939390.511235955056180.4989429175475690.2114164904862582.031712473572941.1120507399577201
29Saudi Arabia250.20.560439560439560.4170616113744080.4832451499118170.2275132275132281.596119929453261.04585537918871[null][null]
30Nigeria240.2916666666666670.620370370370370.3190476190476190.4580152671755730.2958015267175571.496183206106871.0038167938931303
31Scotland230.1739130434782610.584775086505190.3942307692307690.4765100671140940.217449664429531.75033557046981.2255033557047[null][null]
32Colombia230.3913043478260870.468750.3571428571428570.3780.2721.2061.2101
33Romania210.3809523809523810.5922330097087380.3118644067796610.4401840490797550.2561349693251531.645705521472391.28834355828221[null][null]
34Denmark190.5263157894736840.5525423728813560.3466666666666670.446071904127830.2037283621837551.777629826897471.4287616511318201
35South Africa170.1764705882352940.527559055118110.3709677419354840.4447592067988670.2747875354107651.33994334277621.00849858356941[null][null]
36Croatia160.43750.6705882352941180.4257425742574260.5338345864661650.2706766917293231.751879699248120.981203007518797[null][null]
37Costa Rica150.3333333333333330.6238532110091740.3317307692307690.4298724954462660.2568306010928961.670309653916211.16757741347905[null][null]
38Turkey150.4666666666666670.453987730061350.3380281690140850.3819577735124760.2380038387715931.33205374280231.42802303262956[null][null]
39Peru150.2666666666666670.4285714285714290.223602484472050.3129370629370630.2430069930069931.229020979020981.4685314685314702
40Tunisia150.1333333333333330.5315789473684210.2777777777777780.4166666666666670.2916666666666671.433712121212121.0643939393939401
41New Zealand150.00.4868421052631580.3468208092485550.4047619047619050.1815476190476191.747023809523811.61309523809524[null][null]
42Northern Ireland130.2307692307692310.2901785714285710.1721311475409840.2437810945273630.2321724709784411.043117744610281.95356550580431[null][null]
43Morocco130.1538461538461540.6122448979591840.3548387096774190.4516806722689080.3004201680672271.388655462184870.873949579831933[null][null]
44Republic of Ireland130.1538461538461540.4875621890547260.3103448275862070.3919694072657740.2772466539196941.401529636711281.24665391969407[null][null]
45Greece130.1538461538461540.4590163934426230.2626262626262630.3650190114068440.2528517110266161.239543726235741.4201520912547501
46Algeria130.2307692307692310.5806451612903230.316384180790960.4152173913043480.2804347826086961.354347826086961.030434782608701
47Iran120.08333333333333330.6415094339622640.4303797468354430.5343680709534370.2616407982261641.840354767184040.83592017738359202
48Ghana120.3333333333333330.6727272727272730.3840579710144930.482206405693950.2562277580071171.64234875444841.0409252669039102
49Ivory Coast110.2727272727272730.6917293233082710.40.5029469548133590.249508840864441.634577603143421.0530451866404702
50Egypt100.10.5823529411764710.3739130434782610.4863013698630140.251.643835616438361.0359589041095905
51Ecuador100.40.593750.240259740259740.2944915254237290.2457627118644071.194915254237291.6504237288135601
52Honduras90.00.5483870967741940.331606217616580.4085106382978720.2617021276595741.491489361702131.22340425531915[null][null]
53Bolivia90.00.3787878787878790.1386138613861390.2219570405727920.2482100238663481.03818615751791.94272076372315[null][null]
54Norway80.250.3948220064724920.3343465045592710.3599476439790580.2277486910994761.501308900523561.68455497382199[null][null]
55North Korea70.1428571428571430.7333333333333330.4088397790055250.4266666666666670.271.611.03666666666667[null][null]
56United Arab Emirates60.1666666666666670.476821192052980.3368421052631580.3957446808510640.2489361702127661.414893617021281.28510638297872[null][null]
57Canada60.00.3387096774193550.2814814814814810.3314121037463980.2391930835734871.048991354466861.3976945244956802
58Iraq60.00.6666666666666670.4362416107382550.4676113360323890.2773279352226721.621457489878540.94534412955465601
59Slovenia60.1666666666666670.4264705882352940.2857142857142860.3521126760563380.2347417840375591.239436619718311.27230046948357[null][null]
60El Salvador60.00.4819277108433730.2009132420091320.3211206896551720.2262931034482761.226293103448281.48706896551724[null][null]
61Senegal50.40.6480.3360655737704920.4229166666666670.268751.28751.00208333333333[null][null]
62Wales50.20.3670886075949370.2651515151515150.3100649350649350.2126623376623381.253246753246751.69318181818182[null][null]
63Ukraine50.40.5285714285714290.3370786516853930.4405286343612330.2907488986784141.396475770925110.973568281938326[null][null]
64Slovakia40.250.450.3333333333333330.4016064257028110.2369477911646591.441767068273091.30120481927711[null][null]
65Angola30.00.56250.2535211267605630.3527508090614890.3527508090614891.17475728155341.042071197411[null][null]
66Trinidad and Tobago30.00.6224489795918370.3763440860215050.4526484751203850.2102728731942211.739967897271271.27447833065811[null][null]
67Haiti30.00.5304347826086960.3585858585858590.4138755980861240.2320574162679431.56220095693781.31818181818182[null][null]
68Jamaica30.3333333333333330.5304878048780490.3097345132743360.3877159309021110.2284069097888681.318618042226491.33781190019194[null][null]
69Cuba30.3333333333333330.450.3728813559322030.3461538461538460.251.320512820512821.43910256410256[null][null]
70Bosnia and Herzegovina30.3333333333333330.4285714285714290.3048780487804880.3846153846153850.2142857142857141.428571428571431.39010989010989[null][null]
71China PR30.00.5796178343949040.3958333333333330.4881170018281540.2266910420475321.837294332723951.0877513711151701
72Israel30.00.3892617449664430.303278688524590.3492462311557790.2512562814070351.454773869346731.4522613065326601
73Kuwait30.00.4573170731707320.3791666666666670.4240740740740740.2722222222222221.555555555555561.0796296296296301
74Tahiti30.00.4838709677419350.5846153846153850.5183246073298430.125654450261782.518324607329841.70157068062827[null][null]
75DR Congo30.00.6153846153846150.3081081081081080.3913043478260870.2681159420289861.50241545893721.253623188405801
76Togo30.00.4845360824742270.2363636363636360.3142857142857140.2457142857142861.082857142857141.39142857142857[null][null]
77Indonesia10.00.4926470588235290.3590604026845640.3771760154738880.1876208897485491.673114119922631.67504835589942[null][null]
78Montenegro0[null]0.629629629629630.1538461538461540.3561643835616440.260273972602741.205479452054791.35616438356164[null][null]
79Antigua and Barbuda0[null]0.4705882352941180.2333333333333330.3107344632768360.2090395480225991.39548022598871.70056497175141[null][null]
80Gabon0[null]0.4727272727272730.270270270270270.360856269113150.27828746177371.192660550458721.13149847094801[null][null]
81Guyana0[null]0.3870967741935480.2564102564102560.3016528925619830.2066115702479341.198347107438021.74793388429752[null][null]
82Gambia0[null]0.3432835820895520.160.2356020942408380.2879581151832460.937172774869111.45026178010471[null][null]
83Luxembourg0[null]0.1102941176470590.05882352941176470.0690607734806630.118784530386740.5662983425414372.8121546961326[null][null]
84Azerbaijan0[null]0.3617021276595740.1504424778761060.1826923076923080.2644230769230770.6971153846153851.69711538461538[null][null]
85Tonga0[null]0.00.2580645161290320.2708333333333330.1251.18753.375[null][null]
86Northern Cyprus0[null]0.80.40.5333333333333330.06666666666666672.266666666666671.2[null][null]
87Silesia0[null]0.375[null]0.3750.253.02.125[null][null]
88Benin0[null]0.2763157894736840.1372549019607840.2061403508771930.2280701754385961.004385964912281.95175438596491[null][null]
89Burma0[null]0.512195121951220.450.4496855345911950.1729559748427671.713836477987421.4811320754717[null][null]
90Somalia0[null]0.3333333333333330.08333333333333330.08910891089108910.1188118811881190.5049504950495052.8019801980198[null][null]
91Nicaragua0[null]0.60.09890109890109890.1583333333333330.06666666666666670.8253.19166666666667[null][null]
92Malawi0[null]0.4410480349344980.3076923076923080.356736242884250.2808349146110061.239089184060721.29981024667932[null][null]
93British Virgin Islands0[null]0.3636363636363640.160.1975308641975310.1604938271604940.8765432098765433.11111111111111[null][null]
94Andalusia0[null]0.636363636363636[null]0.6363636363636360.3636363636363642.00.818181818181818[null][null]
95Zambia0[null]0.5857988165680470.4084084084084080.4636363636363640.2545454545454551.590909090909091.0272727272727301
96Qatar0[null]0.4936708860759490.3146067415730340.4021276595744680.2489361702127661.41.18297872340426[null][null]
97Basque Country0[null]0.6333333333333330.6956521739130430.6603773584905660.1698113207547172.754716981132081.33962264150943[null][null]
98Libya0[null]0.5876288659793810.2335766423357660.3783783783783780.2466216216216221.290540540540541.21621621621622[null][null]
99Guinea0[null]0.650.2542372881355930.3708920187793430.2910798122065731.363849765258221.22065727699531[null][null]
100Artsakh0[null]1.0[null]1.00.03.00.0[null][null]
Rows: 1-100 | Columns: 13

Let's add each team's confederation to our dataset.

In [28]:
teams_kpi = teams_kpi.join(confederation,
                           how = "left",
                           on = {"team1": "team"},
                           expr2 = ["confederation"])
display(teams_kpi)
Abc
team1
Varchar(64)
123
Number_Games_World_Tournament
Integer
123
Integer
123
Percent_Victory_World_Tournament
Float
123
Float
123
Percent_Victory_Home
Float
123
Percent_Victory_Away
Float
123
Percent_Victory
Float
123
Percent_Draw
Float
123
Avg_goals
Float
123
Avg_goals_conceded
Float
123
nb_World_Cup
Integer
123
nb_Continental_Cup
Integer
Abc
confederation
Varchar(8)
1Madagascar0[null]0.4642857142857140.321839080459770.3666666666666670.1944444444444441.333333333333331.63333333333333[null][null]CAF
2North Vietnam0[null][null]0.2105263157894740.2105263157894740.1578947368421051.631578947368422.26315789473684[null][null]OFC
3Abkhazia0[null][null]0.1666666666666670.1666666666666670.51.01.5[null][null]OFC
4Canada60.00.3387096774193550.2814814814814810.3314121037463980.2391930835734871.048991354466861.3976945244956802CONCACAF
5Monaco0[null][null]0.1666666666666670.1666666666666670.1666666666666671.166666666666678.33333333333333[null][null]OFC
6Saint Pierre and Miquelon0[null][null]0.00.00.00.16666666666666710.3333333333333[null][null]OFC
7Algeria130.2307692307692310.5806451612903230.316384180790960.4152173913043480.2804347826086961.354347826086961.030434782608701CAF
8Iran120.08333333333333330.6415094339622640.4303797468354430.5343680709534370.2616407982261641.840354767184040.83592017738359202AFC
9Comoros0[null]0.00.1428571428571430.07142857142857140.2857142857142860.51.71428571428571[null][null]CAF
10Namibia0[null]0.3518518518518520.1954022988505750.2368421052631580.2842105263157891.015789473684211.53157894736842[null][null]CAF
11South Sudan0[null]0.50.1428571428571430.1666666666666670.2777777777777780.5555555555555561.55555555555556[null][null]CAF
12Belize0[null]0.50.0370370370370370.1864406779661020.1694915254237291.033898305084752.23728813559322[null][null]OFC
13Vietnam0[null]0.465517241379310.3846153846153850.3765432098765430.2037037037037041.666666666666671.59259259259259[null][null]AFC
14Puerto Rico0[null]0.1785714285714290.1960784313725490.1881188118811880.1782178217821781.009900990099012.2970297029703[null][null]OFC
15Andorra0[null]0.05714285714285710.00.02290076335877860.07633587786259540.2824427480916032.82442748091603[null][null]UEFA
16France690.5362318840579710.5321100917431190.3636363636363640.4808184143222510.2148337595907931.758312020460361.3427109974424612UEFA
17Belarus0[null]0.3928571428571430.2857142857142860.306220095693780.2583732057416271.253588516746411.44019138755981[null][null]UEFA
18Ynys Môn0[null][null]0.4705882352941180.4705882352941180.2156862745098041.705882352941181.49019607843137[null][null]OFC
19Guatemala0[null]0.4680851063829790.2857142857142860.3412322274881520.2582938388625591.329383886255921.3696682464455[null][null]CONCACAF
20Turkmenistan0[null]0.5384615384615380.3650793650793650.3846153846153850.1709401709401711.632478632478631.47863247863248[null][null]AFC
21China PR30.00.5796178343949040.3958333333333330.4881170018281540.2266910420475321.837294332723951.0877513711151701AFC
22Serbia430.3953488372093020.5445026178010470.381502890173410.4564606741573030.2191011235955061.816011235955061.37921348314607[null][null]UEFA
23Italy910.5274725274725270.6438848920863310.3464566929133860.5245683930942890.2828685258964141.695883134130150.9827357237715831UEFA
24Uganda0[null]0.5919540229885060.3827893175074180.4404973357015990.2539964476021311.618117229129661.2113676731794[null][null]CAF
25Bermuda0[null]0.4038461538461540.2444444444444440.3538461538461540.1846153846153851.676923076923081.56153846153846[null][null]CONCACAF
26Niger0[null]0.4482758620689660.08988764044943820.2349726775956280.2568306010928960.9344262295081971.6448087431694[null][null]CAF
27Rwanda0[null]0.4464285714285710.3247863247863250.3333333333333330.2535211267605631.051643192488261.22535211267606[null][null]CAF
28Brunei0[null]0.50.1111111111111110.10.06666666666666670.653.76666666666667[null][null]OFC
29Guadeloupe0[null]0.5076923076923080.3802816901408450.4155251141552510.1826484018264841.671232876712331.48401826484018[null][null]CONCACAF
30Panama0[null]0.50.2160493827160490.3101604278074870.2540106951871661.163101604278071.56417112299465[null][null]CONMEBOL
31United States480.2916666666666670.4065420560747660.2620689655172410.4196141479099680.2122186495176851.419614147909971.3713826366559502CONMEBOL
32Sierra Leone0[null]0.5416666666666670.1949152542372880.3083333333333330.2416666666666670.9583333333333331.3625[null][null]CAF
33Costa Rica150.3333333333333330.6238532110091740.3317307692307690.4298724954462660.2568306010928961.670309653916211.16757741347905[null][null]CONMEBOL
34Hitra0[null][null]0.1666666666666670.1666666666666670.01.166666666666674.83333333333333[null][null]OFC
35Iraqi Kurdistan0[null]1.00.3529411764705880.450.252.11.15[null][null]OFC
36Philippines0[null]0.4761904761904760.2272727272727270.2746113989637310.1450777202072541.165803108808292.27979274611399[null][null]AFC
37Singapore0[null]0.4067796610169490.2443609022556390.3040935672514620.1929824561403511.339181286549711.87329434697856[null][null]AFC
38Macau0[null]0.2173913043478260.1428571428571430.1415094339622640.09433962264150940.7641509433962263.26415094339623[null][null]AFC
39Mali0[null]0.5680.3255813953488370.3995633187772930.2467248908296941.272925764192141.17685589519651[null][null]CAF
40Czech Republic380.3684210526315790.6543209876543210.341853035143770.4833110814419230.2216288384512681.84379172229641.23497997329773[null][null]UEFA
41Bangladesh0[null]0.5517241379310340.1792452830188680.2324324324324320.2108108108108110.870270270270272.02702702702703[null][null]AFC
42U.S. Virgin Islands0[null]0.20.00.10.150.54.875[null][null]OFC
43Zimbabwe0[null]0.5403225806451610.3720930232558140.418719211822660.256157635467981.352216748768471.16748768472906[null][null]CAF
44Papua New Guinea0[null]0.3333333333333330.240.2680412371134020.1752577319587631.907216494845362.22680412371134[null][null]OFC
45Greece130.1538461538461540.4590163934426230.2626262626262630.3650190114068440.2528517110266161.239543726235741.4201520912547501UEFA
46Réunion0[null]0.2121212121212120.4166666666666670.3333333333333330.1604938271604941.666666666666672.35802469135802[null][null]OFC
47Mauritania0[null]0.30.08571428571428570.150289017341040.2601156069364160.7341040462427751.64161849710983[null][null]CAF
48Eswatini0[null]0.2409638554216870.1770833333333330.2070707070707070.2727272727272730.8282828282828281.74242424242424[null][null]CAF
49Iceland0[null]0.4307692307692310.237804878048780.2974358974358970.189743589743591.164102564102561.7[null][null]UEFA
50Germany1200.60.6083916083916080.4702127659574470.5553691275167780.2080536912751682.09983221476511.1795302013422843UEFA
51Botswana0[null]0.3823529411764710.1470588235294120.2655601659751040.3029045643153530.7966804979253111.29460580912863[null][null]CAF
52Eritrea0[null]0.4166666666666670.120.1571428571428570.2285714285714290.6714285714285711.74285714285714[null][null]CAF
53Sudan0[null]0.5921052631578950.2783018867924530.3360.2481.141333333333331.36801CAF
54Turks and Caicos Islands0[null][null]0.2222222222222220.1764705882352940.05882352941176470.5882352941176473.41176470588235[null][null]OFC
55Grenada0[null]0.40.3539823008849560.3526315789473680.2210526315789471.789473684210531.76315789473684[null][null]CONCACAF
56Kosovo0[null]0.40.50.4285714285714290.2857142857142862.01.71428571428571[null][null]UEFA
57Tuvalu0[null][null]0.2105263157894740.2105263157894740.1052631578947371.157894736842115.31578947368421[null][null]OFC
58Nepal0[null]0.3947368421052630.1463414634146340.2066666666666670.140.8133333333333332.58666666666667[null][null]AFC
59Kiribati0[null][null]0.00.00.00.3333333333333339.66666666666667[null][null]OFC
60Guinea-Bissau0[null]0.4516129032258060.2307692307692310.2727272727272730.2231404958677691.033057851239671.56198347107438[null][null]CAF
61Bahamas0[null]0.3333333333333330.1818181818181820.2592592592592590.1481481481481481.148148148148153.33333333333333[null][null]OFC
62New Zealand150.00.4868421052631580.3468208092485550.4047619047619050.1815476190476191.747023809523811.61309523809524[null][null]OFC
63Mozambique0[null]0.5306122448979590.20.3150183150183150.2527472527472531.054945054945051.28571428571429[null][null]CAF
64Uruguay610.4098360655737710.50.3007246376811590.4302741358760430.2455303933253871.575685339690111.2646007151370728CONMEBOL
65Saint Martin0[null]0.750.160.3030303030303030.09090909090909091.121212121212122.90909090909091[null][null]OFC
66Albania0[null]0.4042553191489360.1730769230769230.239726027397260.2226027397260270.9006849315068491.5958904109589[null][null]UEFA
67Angola30.00.56250.2535211267605630.3527508090614890.3527508090614891.17475728155341.042071197411[null][null]CAF
68Brazil1370.6788321167883210.7333333333333330.593750.6350914962325080.200215285252962.193756727664160.9375672766415548CONMEBOL
69Scotland230.1739130434782610.584775086505190.3942307692307690.4765100671140940.217449664429531.75033557046981.2255033557047[null][null]UEFA
70Dominican Republic0[null]0.4285714285714290.3333333333333330.3626373626373630.1428571428571431.571428571428571.85714285714286[null][null]OFC
71Alderney0[null][null]0.08333333333333330.08333333333333330.00.5833333333333334.33333333333333[null][null]OFC
72Colombia230.3913043478260870.468750.3571428571428570.3780.2721.2061.2101CONMEBOL
73Bonaire0[null][null]0.3076923076923080.3076923076923080.1538461538461541.615384615384623.38461538461538[null][null]OFC
74Palestine0[null]0.00.250.2516556291390730.2649006622516561.284768211920531.60264900662252[null][null]AFC
75Kazakhstan0[null]0.3947368421052630.160.2392638036809820.2392638036809821.036809815950921.6441717791411[null][null]UEFA
76Arameans Suryoye0[null][null]0.5714285714285710.5714285714285710.1428571428571431.428571428571431.14285714285714[null][null]OFC
77Togo30.00.4845360824742270.2363636363636360.3142857142857140.2457142857142861.082857142857141.39142857142857[null][null]CAF
78Central African Republic0[null]0.3529411764705880.120.1688311688311690.2077922077922081.025974025974032.06493506493507[null][null]CAF
79South Africa170.1764705882352940.527559055118110.3709677419354840.4447592067988670.2747875354107651.33994334277621.00849858356941[null][null]CAF
80Zanzibar0[null]0.1724137931034480.190476190476190.1878172588832490.1928934010152280.8883248730964472.16243654822335[null][null]OFC
81Pakistan0[null]0.3666666666666670.2049180327868850.1978021978021980.1868131868131870.9340659340659342.39010989010989[null][null]AFC
82Mongolia0[null]1.00.2413793103448280.2666666666666670.08888888888888891.088888888888893.22222222222222[null][null]OFC
83Vietnam Republic0[null]0.6153846153846150.390476190476190.4313725490196080.1764705882352941.836601307189541.73202614379085[null][null]AFC
84Curaçao0[null]0.6666666666666670.2944444444444440.3564356435643560.2673267326732671.547854785478551.67656765676568[null][null]CONCACAF
85Venezuela0[null]0.4705882352941180.2386363636363640.235988200589970.2064896755162240.9941002949852512.01769911504425[null][null]CONMEBOL
86Raetia0[null][null]0.00.00.00.05.0[null][null]OFC
87Anguilla0[null]0.00.093750.06250.06250.6666666666666674.04166666666667[null][null]OFC
88Gotland0[null]0.60.2857142857142860.3461538461538460.1538461538461542.461538461538462.0[null][null]OFC
89Jordan0[null]0.4112149532710280.2866242038216560.3479532163742690.2865497076023391.184210526315791.1140350877193[null][null]AFC
90Tamil Eelam0[null][null]0.1666666666666670.1666666666666670.01.04.16666666666667[null][null]OFC
91Sri Lanka0[null]0.3333333333333330.203539823008850.2111111111111110.1777777777777781.038888888888892.43888888888889[null][null]AFC
92Nigeria240.2916666666666670.620370370370370.3190476190476190.4580152671755730.2958015267175571.496183206106871.0038167938931303CAF
93Ellan Vannin0[null][null]0.00.00.6666666666666670.6666666666666671.0[null][null]OFC
94Northern Mariana Islands0[null]0.00.1333333333333330.1111111111111110.05555555555555560.8888888888888894.16666666666667[null][null]OFC
95Montserrat0[null]1.00.1052631578947370.1333333333333330.06666666666666671.033333333333334.4[null][null]OFC
96Georgia0[null]0.4909090909090910.230.2935323383084580.1890547263681591.129353233830851.48258706467662[null][null]UEFA
97Lesotho0[null]0.2168674698795180.1509433962264150.1690140845070420.3098591549295770.7793427230046951.61971830985915[null][null]CAF
98El Salvador60.00.4819277108433730.2009132420091320.3211206896551720.2262931034482761.226293103448281.48706896551724[null][null]CONCACAF
99South Ossetia0[null][null]0.00.00.3333333333333330.6666666666666672.33333333333333[null][null]OFC
100Latvia0[null]0.4166666666666670.250.3011363636363640.2272727272727271.255681818181821.64488636363636[null][null]UEFA
Rows: 1-100 | Columns: 14

Since clustering will use different statistics, we need to normalize the data. We'll also create a dummy that will equal 1 if the team won at least one World Cup.

In [29]:
teams_kpi.normalize(columns = ["Number_Games_Continental_Tournament", 
                               "Number_Games_World_Tournament",
                               "nb_Continental_Cup"],
                    method = "minmax")
teams_kpi["Word_Cup_Victory"] = teams_kpi["nb_World_Cup"] > 0
teams_kpi["Word_Cup_Victory"].astype("int")
Out[29]:
Abc
team1
Varchar(64)
123
Number_Games_World_Tournament
Float
123
Float
123
Percent_Victory_World_Tournament
Float
123
Float
123
Percent_Victory_Home
Float
123
Percent_Victory_Away
Float
123
Percent_Victory
Float
123
Percent_Draw
Float
123
Avg_goals
Float
123
Avg_goals_conceded
Float
123
nb_World_Cup
Integer
123
nb_Continental_Cup
Float
Abc
confederation
Varchar(8)
123
Word_Cup_Victory
Int
1Madagascar0.0[null]0.4642857142857140.321839080459770.3666666666666670.1944444444444441.333333333333331.63333333333333[null][null]CAF[null]
2North Vietnam0.0[null][null]0.2105263157894740.2105263157894740.1578947368421051.631578947368422.26315789473684[null][null]OFC[null]
3Abkhazia0.0[null][null]0.1666666666666670.1666666666666670.51.01.5[null][null]OFC[null]
4Canada0.0437956204379560.00.3387096774193550.2814814814814810.3314121037463980.2391930835734871.048991354466861.3976945244956800.25CONCACAF0
5Monaco0.0[null][null]0.1666666666666670.1666666666666670.1666666666666671.166666666666678.33333333333333[null][null]OFC[null]
6Saint Pierre and Miquelon0.0[null][null]0.00.00.00.16666666666666710.3333333333333[null][null]OFC[null]
7Algeria0.0948905109489050.2307692307692310.5806451612903230.316384180790960.4152173913043480.2804347826086961.354347826086961.030434782608700.125CAF0
8Iran0.0875912408759120.08333333333333330.6415094339622640.4303797468354430.5343680709534370.2616407982261641.840354767184040.83592017738359200.25AFC0
9Comoros0.0[null]0.00.1428571428571430.07142857142857140.2857142857142860.51.71428571428571[null][null]CAF[null]
10Namibia0.0[null]0.3518518518518520.1954022988505750.2368421052631580.2842105263157891.015789473684211.53157894736842[null][null]CAF[null]
11South Sudan0.0[null]0.50.1428571428571430.1666666666666670.2777777777777780.5555555555555561.55555555555556[null][null]CAF[null]
12Belize0.0[null]0.50.0370370370370370.1864406779661020.1694915254237291.033898305084752.23728813559322[null][null]OFC[null]
13Vietnam0.0[null]0.465517241379310.3846153846153850.3765432098765430.2037037037037041.666666666666671.59259259259259[null][null]AFC[null]
14Puerto Rico0.0[null]0.1785714285714290.1960784313725490.1881188118811880.1782178217821781.009900990099012.2970297029703[null][null]OFC[null]
15Andorra0.0[null]0.05714285714285710.00.02290076335877860.07633587786259540.2824427480916032.82442748091603[null][null]UEFA[null]
16France0.5036496350364960.5362318840579710.5321100917431190.3636363636363640.4808184143222510.2148337595907931.758312020460361.3427109974424610.25UEFA1
17Belarus0.0[null]0.3928571428571430.2857142857142860.306220095693780.2583732057416271.253588516746411.44019138755981[null][null]UEFA[null]
18Ynys Môn0.0[null][null]0.4705882352941180.4705882352941180.2156862745098041.705882352941181.49019607843137[null][null]OFC[null]
19Guatemala0.0[null]0.4680851063829790.2857142857142860.3412322274881520.2582938388625591.329383886255921.3696682464455[null][null]CONCACAF[null]
20Turkmenistan0.0[null]0.5384615384615380.3650793650793650.3846153846153850.1709401709401711.632478632478631.47863247863248[null][null]AFC[null]
21China PR0.0218978102189780.00.5796178343949040.3958333333333330.4881170018281540.2266910420475321.837294332723951.0877513711151700.125AFC0
22Serbia0.3138686131386860.3953488372093020.5445026178010470.381502890173410.4564606741573030.2191011235955061.816011235955061.37921348314607[null][null]UEFA[null]
23Italy0.6642335766423360.5274725274725270.6438848920863310.3464566929133860.5245683930942890.2828685258964141.695883134130150.9827357237715830.125UEFA1
24Uganda0.0[null]0.5919540229885060.3827893175074180.4404973357015990.2539964476021311.618117229129661.2113676731794[null][null]CAF[null]
25Bermuda0.0[null]0.4038461538461540.2444444444444440.3538461538461540.1846153846153851.676923076923081.56153846153846[null][null]CONCACAF[null]
26Niger0.0[null]0.4482758620689660.08988764044943820.2349726775956280.2568306010928960.9344262295081971.6448087431694[null][null]CAF[null]
27Rwanda0.0[null]0.4464285714285710.3247863247863250.3333333333333330.2535211267605631.051643192488261.22535211267606[null][null]CAF[null]
28Brunei0.0[null]0.50.1111111111111110.10.06666666666666670.653.76666666666667[null][null]OFC[null]
29Guadeloupe0.0[null]0.5076923076923080.3802816901408450.4155251141552510.1826484018264841.671232876712331.48401826484018[null][null]CONCACAF[null]
30Panama0.0[null]0.50.2160493827160490.3101604278074870.2540106951871661.163101604278071.56417112299465[null][null]CONMEBOL[null]
31United States0.350364963503650.2916666666666670.4065420560747660.2620689655172410.4196141479099680.2122186495176851.419614147909971.3713826366559500.25CONMEBOL0
32Sierra Leone0.0[null]0.5416666666666670.1949152542372880.3083333333333330.2416666666666670.9583333333333331.3625[null][null]CAF[null]
33Costa Rica0.1094890510948910.3333333333333330.6238532110091740.3317307692307690.4298724954462660.2568306010928961.670309653916211.16757741347905[null][null]CONMEBOL[null]
34Hitra0.0[null][null]0.1666666666666670.1666666666666670.01.166666666666674.83333333333333[null][null]OFC[null]
35Iraqi Kurdistan0.0[null]1.00.3529411764705880.450.252.11.15[null][null]OFC[null]
36Philippines0.0[null]0.4761904761904760.2272727272727270.2746113989637310.1450777202072541.165803108808292.27979274611399[null][null]AFC[null]
37Singapore0.0[null]0.4067796610169490.2443609022556390.3040935672514620.1929824561403511.339181286549711.87329434697856[null][null]AFC[null]
38Macau0.0[null]0.2173913043478260.1428571428571430.1415094339622640.09433962264150940.7641509433962263.26415094339623[null][null]AFC[null]
39Mali0.0[null]0.5680.3255813953488370.3995633187772930.2467248908296941.272925764192141.17685589519651[null][null]CAF[null]
40Czech Republic0.2773722627737230.3684210526315790.6543209876543210.341853035143770.4833110814419230.2216288384512681.84379172229641.23497997329773[null][null]UEFA[null]
41Bangladesh0.0[null]0.5517241379310340.1792452830188680.2324324324324320.2108108108108110.870270270270272.02702702702703[null][null]AFC[null]
42U.S. Virgin Islands0.0[null]0.20.00.10.150.54.875[null][null]OFC[null]
43Zimbabwe0.0[null]0.5403225806451610.3720930232558140.418719211822660.256157635467981.352216748768471.16748768472906[null][null]CAF[null]
44Papua New Guinea0.0[null]0.3333333333333330.240.2680412371134020.1752577319587631.907216494845362.22680412371134[null][null]OFC[null]
45Greece0.0948905109489050.1538461538461540.4590163934426230.2626262626262630.3650190114068440.2528517110266161.239543726235741.4201520912547500.125UEFA0
46Réunion0.0[null]0.2121212121212120.4166666666666670.3333333333333330.1604938271604941.666666666666672.35802469135802[null][null]OFC[null]
47Mauritania0.0[null]0.30.08571428571428570.150289017341040.2601156069364160.7341040462427751.64161849710983[null][null]CAF[null]
48Eswatini0.0[null]0.2409638554216870.1770833333333330.2070707070707070.2727272727272730.8282828282828281.74242424242424[null][null]CAF[null]
49Iceland0.0[null]0.4307692307692310.237804878048780.2974358974358970.189743589743591.164102564102561.7[null][null]UEFA[null]
50Germany0.8759124087591240.60.6083916083916080.4702127659574470.5553691275167780.2080536912751682.09983221476511.1795302013422840.375UEFA1
51Botswana0.0[null]0.3823529411764710.1470588235294120.2655601659751040.3029045643153530.7966804979253111.29460580912863[null][null]CAF[null]
52Eritrea0.0[null]0.4166666666666670.120.1571428571428570.2285714285714290.6714285714285711.74285714285714[null][null]CAF[null]
53Sudan0.0[null]0.5921052631578950.2783018867924530.3360.2481.141333333333331.36800.125CAF0
54Turks and Caicos Islands0.0[null][null]0.2222222222222220.1764705882352940.05882352941176470.5882352941176473.41176470588235[null][null]OFC[null]
55Grenada0.0[null]0.40.3539823008849560.3526315789473680.2210526315789471.789473684210531.76315789473684[null][null]CONCACAF[null]
56Kosovo0.0[null]0.40.50.4285714285714290.2857142857142862.01.71428571428571[null][null]UEFA[null]
57Tuvalu0.0[null][null]0.2105263157894740.2105263157894740.1052631578947371.157894736842115.31578947368421[null][null]OFC[null]
58Nepal0.0[null]0.3947368421052630.1463414634146340.2066666666666670.140.8133333333333332.58666666666667[null][null]AFC[null]
59Kiribati0.0[null][null]0.00.00.00.3333333333333339.66666666666667[null][null]OFC[null]
60Guinea-Bissau0.0[null]0.4516129032258060.2307692307692310.2727272727272730.2231404958677691.033057851239671.56198347107438[null][null]CAF[null]
61Bahamas0.0[null]0.3333333333333330.1818181818181820.2592592592592590.1481481481481481.148148148148153.33333333333333[null][null]OFC[null]
62New Zealand0.1094890510948910.00.4868421052631580.3468208092485550.4047619047619050.1815476190476191.747023809523811.61309523809524[null][null]OFC[null]
63Mozambique0.0[null]0.5306122448979590.20.3150183150183150.2527472527472531.054945054945051.28571428571429[null][null]CAF[null]
64Uruguay0.4452554744525550.4098360655737710.50.3007246376811590.4302741358760430.2455303933253871.575685339690111.2646007151370721.0CONMEBOL1
65Saint Martin0.0[null]0.750.160.3030303030303030.09090909090909091.121212121212122.90909090909091[null][null]OFC[null]
66Albania0.0[null]0.4042553191489360.1730769230769230.239726027397260.2226027397260270.9006849315068491.5958904109589[null][null]UEFA[null]
67Angola0.0218978102189780.00.56250.2535211267605630.3527508090614890.3527508090614891.17475728155341.042071197411[null][null]CAF[null]
68Brazil1.00.6788321167883210.7333333333333330.593750.6350914962325080.200215285252962.193756727664160.9375672766415541.0CONMEBOL1
69Scotland0.1678832116788320.1739130434782610.584775086505190.3942307692307690.4765100671140940.217449664429531.75033557046981.2255033557047[null][null]UEFA[null]
70Dominican Republic0.0[null]0.4285714285714290.3333333333333330.3626373626373630.1428571428571431.571428571428571.85714285714286[null][null]OFC[null]
71Alderney0.0[null][null]0.08333333333333330.08333333333333330.00.5833333333333334.33333333333333[null][null]OFC[null]
72Colombia0.1678832116788320.3913043478260870.468750.3571428571428570.3780.2721.2061.2100.125CONMEBOL0
73Bonaire0.0[null][null]0.3076923076923080.3076923076923080.1538461538461541.615384615384623.38461538461538[null][null]OFC[null]
74Palestine0.0[null]0.00.250.2516556291390730.2649006622516561.284768211920531.60264900662252[null][null]AFC[null]
75Kazakhstan0.0[null]0.3947368421052630.160.2392638036809820.2392638036809821.036809815950921.6441717791411[null][null]UEFA[null]
76Arameans Suryoye0.0[null][null]0.5714285714285710.5714285714285710.1428571428571431.428571428571431.14285714285714[null][null]OFC[null]
77Togo0.0218978102189780.00.4845360824742270.2363636363636360.3142857142857140.2457142857142861.082857142857141.39142857142857[null][null]CAF[null]
78Central African Republic0.0[null]0.3529411764705880.120.1688311688311690.2077922077922081.025974025974032.06493506493507[null][null]CAF[null]
79South Africa0.1240875912408760.1764705882352940.527559055118110.3709677419354840.4447592067988670.2747875354107651.33994334277621.00849858356941[null][null]CAF[null]
80Zanzibar0.0[null]0.1724137931034480.190476190476190.1878172588832490.1928934010152280.8883248730964472.16243654822335[null][null]OFC[null]
81Pakistan0.0[null]0.3666666666666670.2049180327868850.1978021978021980.1868131868131870.9340659340659342.39010989010989[null][null]AFC[null]
82Mongolia0.0