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:
# Start your code here!
import pandas as pd
import matplotlib.pyplot as plt
from scipy.stats import shapiro
import pingouin as pg
import numpy as np
#reading csv for man and woman
man_result = pd.read_csv('men_results.csv')
wman_result = pd.read_csv('women_results.csv')
#Dropping missing value
man_na = man_result.dropna()
wman_na = wman_result.dropna()
#filtering data for man_filtered
man_filtered = man_na[(man_na['tournament']=='FIFA World Cup') & (man_na['date'] >= '2002-01-01')]
man_filtered['total_goal'] = man_filtered['home_score'] + man_filtered['away_score']
#filtering data for wman_filtered
wman_filtered = wman_na[(wman_na['tournament']=='FIFA World Cup') & (wman_na['date'] >= '2002-01-01')]
wman_filtered['total_goal'] = wman_filtered['home_score'] + wman_filtered['away_score']
# Shapiro-Wilk test for normality
shapiro_man = shapiro(man_filtered['total_goal'])
shapiro_woman = shapiro(wman_filtered['total_goal'])
#Performing hypothesis test
mwu_result = pg.mwu(
x=wman_filtered['total_goal'],
y=man_filtered['total_goal'],
alternative='greater'
)
#interpreting the result of the hypothesis test
p_val = mwu_result['p-val'].to_numpy()[0].round(3)
result = 'reject'
result_dict = {"p_val" : p_val, "result" : result}
print(result_dict)