Skip to content
Project: Hypothesis Testing with Men's and Women's Soccer Matches
  • AI Chat
  • Code
  • Report
  • Introduction

    You're working as a sports journalist at a major online sports media company, specializing in soccer analysis and reporting. You've been watching both men's and women's international soccer matches for a number of years, and your gut instinct tells you that more goals are scored in women's international football matches than men's. This would make an interesting investigative article that your subscribers are bound to love, but you'll need to perform a valid statistical hypothesis test to be sure!

    While scoping this project, you acknowledge that the sport has changed a lot over the years, and performances likely vary a lot depending on the tournament, so you decide to limit the data used in the analysis to only official FIFA World Cup matches (not including qualifiers) since 2002-01-01.

    You create two datasets containing the results of every official men's and women's international football match since the 19th century, which you scraped from a reliable online source. This data is stored in two CSV files: women_results.csv and men_results.csv.

    The question you are trying to determine the answer to is:

    Are more goals scored in women's international soccer matches than men's?

    You assume a 10% significance level, and use the following null and alternative hypotheses:

    : The mean number of goals scored in women's international soccer matches is the same as men's.

    : The mean number of goals scored in women's international soccer matches is greater than men's.

    Import libraries

    import pandas as pd
    import matplotlib.pyplot as plt
    import seaborn as sns
    import numpy as np
    from scipy.stats import mannwhitneyu
    !pip install pingouin
    import pingouin
    
    plt.style.use('bmh')
    Hidden output
    # Load men's results from CSV file
    men = pd.read_csv('men_results.csv')
    
    # Load women's results from CSV file
    women = pd.read_csv('women_results.csv')

    Preview datasets

    # Display the first few rows 
    men.head()
    # Display the first few rows 
    women.head()
    # Display summary information about the men
    men.info()
    # Display summary information about the women
    women.info()

    Filtering data

    # Convert date column to datetime
    men['date'] = pd.to_datetime(men['date'])
    women['date'] = pd.to_datetime(women['date'])
    # Preview the tournaments
    display(men.tournament.value_counts())
    display(women.tournament.value_counts())
    # Extract FIFA World Cup matches only 
    men_wc = men.loc[men.tournament == 'FIFA World Cup']
    women_wc = women.loc[women.tournament == 'FIFA World Cup']
    
    # Matches after 2002-01-01
    men_wc_02 = men_wc.loc[men_wc.date >= '2002-01-01']
    women_wc_02 = women_wc.loc[women_wc.date >= '2002-01-01']
    print('Men dataset :',men_wc_02.shape)
    print('Women dataset :',women_wc_02.shape)

    Exploratory Data Analysis