Soccer Through the Ages
This dataset contains information on international soccer games throughout the years. It includes results of soccer games and information about the players who scored the goals. The dataset contains data from 1872 up to 2023.
💾 The data
data/results.csv
- CSV with results of soccer games between 1872 and 2023home_score
- The score of the home team, excluding penalty shootoutsaway_score
- The score of the away team, excluding penalty shootoutstournament
- The name of the tournamentcity
- The name of the city where the game was playedcountry
- The name of the country where the game was playedneutral
- Whether the game was played at a neutral venue or not
data/shootouts.csv
- CSV with results of penalty shootouts in the soccer gameswinner
- The team that won the penalty shootout
data/goalscorers.csv
- CSV with information on goal scorers of some of the soccer games in the results CSVteam
- The team that scored the goalscorer
- The player who scored the goalminute
- The minute in the game when the goal was scoredown_goal
- Whether it was an own goal or notpenalty
- Whether the goal was scored as a penalty or not
The following columns can be found in all datasets:
date
- The date of the soccer gamehome_team
- The team that played at homeaway_team
- The team that played away
These shared columns fully identify the game that was played and can be used to join data between the different CSV files.
Source: GitHub
📊 Some guiding questions and visualization to help you explore this data:
- Which are the 15 countries that have won the most games since 1960? Show them in a horizontal bar plot.
- How many goals are scored in total in each minute of the game? Show this in a bar plot, with the minutes on the x-axis. If you're up for the challenge, you could even create an animated Plotly plot that shows how the distribution has changed over the years.
- Which 10 players have scored the most hat-tricks?
- What is the proportion of games won by each team at home and away? What is the difference between the proportions?
- How many games have been won by the home team? And by the away team?
💼 Develop a case study for your portfolio
After exploring the data, you can create a comprehensive case study using this dataset. We have provided an example objective below, but feel free to come up with your own - the world is your oyster!
Example objective: The UEFA Euro 2024 tournament is approaching. Utilize the historical data to construct a predictive model that forecasts potential outcomes of the tournament based on the team draws. Since the draws are not known yet, you should be able to configure them as variables in your notebook.
Which are the 15 countries that have won the most games since 1960? Show them in a horizontal bar plot.
WITH winner AS (
SELECT LEFT(r.date, 10) AS date,
CASE WHEN r.home_score > r.away_score THEN r.home_team
WHEN r.home_score = r.away_score THEN '-'
ELSE r.away_team END AS winner
FROM 'data/results.csv' AS r
INNER JOIN 'data/goalscorers.csv' AS g
ON g.date = r.date
GROUP BY r.date, r.home_score, r.away_score, r.home_team, r.away_team)
SELECT winner,
COUNT(winner) AS games_won,
FROM winner
WHERE winner <> '-'
GROUP BY winner
ORDER BY games_won DESC
LIMIT 15;
How many goals are scored in total in each minute of the game? Show this in a bar plot, with the minutes on the x-
SELECT minute::INT AS minute,
COUNT(scorer) AS total_goals
FROM 'data/goalscorers.csv'
WHERE minute <> 'NA'
GROUP BY minute
ORDER BY minute ASC
Which 10 players have scored the most hat-tricks?
WITH hattrick_scorer AS (
SELECT LEFT(date, 10) AS date,
scorer,
team,
COUNT(scorer) AS num_goals_scored
FROM 'data/goalscorers.csv'
WHERE scorer <> 'NA'
GROUP BY date, scorer, team
HAVING num_goals_scored >= 3
ORDER BY num_goals_scored DESC)
SELECT scorer,
team,
COUNT(scorer) AS num_of_hattricks
FROM hattrick_scorer
GROUP BY scorer, team
ORDER BY num_of_hattricks DESC
LIMIT 10;
How many games have been won by the home team?
WITH which_side_wins AS (
SELECT LEFT(date, 10) AS date,
CASE WHEN home_score > away_score THEN 'home_wins'
ELSE 'away_wins' END AS winner
FROM 'data/results.csv')
SELECT COUNT(winner) AS home_wins,
FROM which_side_wins
WHERE winner = 'home_wins'