Skip to content

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

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

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

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

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

We 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 Python relevant packages for the project
import pandas as pd
import numpy as np
from scipy.stats import t
import matplotlib.pyplot as plt
import pingouin as pg
# read both datasets from csv files
women_results = pd.read_csv("women_results.csv")
men_results = pd.read_csv("men_results.csv")

print(women_results, men_results)
# filter each dataset for time interval of interest
women_results = women_results[women_results["date"]>="2002-01-01"]
men_results = men_results[men_results["date"]>="2002-01-01"]

# filter each dataset for competition of interest
women_results = women_results[women_results["tournament"]=="FIFA World Cup"]
men_results = men_results[men_results["tournament"]=="FIFA World Cup"]

# calculate total goals scored on each match for each dataser
women_results["women_total_score"] = women_results["home_score"] + women_results["away_score"]
men_results["men_total_score"] = men_results["home_score"] + men_results["away_score"]

print(women_results, men_results)
# visualize distribution of total goals
fig, ax = plt.subplots()
ax.hist(women_results["women_total_score"], label="women total score", histtype="step", bins=15)
ax.hist(men_results["men_total_score"], label="men total score", histtype="step", bins=15)
ax.set_xlabel("Total score")
ax.set_ylabel("# of observations")
ax.legend()
# crate new dataframe with total scores of both datasets preparing for statistical test
women_vs_men = pd.DataFrame(data=women_results["women_total_score"])
women_vs_men = pd.concat((women_vs_men, men_results["men_total_score"]), axis=1)

# run Mann-Whitney U Test for non-parametric distribution of 2 independet variables
pg.mwu(x=women_vs_men["women_total_score"], y=women_vs_men["men_total_score"], alternative='greater')
result_dict = {"p_val": 0.0051066098, "result" : "reject"}
print(result_dict)

Conclusion: Since the p value from the Mann-Whitney U Test is lower than our 10% of significance level, the null hypothesis "The mean number of goals scored in women's international soccer matches is the same as men's" is rejected.