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:
# Importing the Libraries
import pandas as pd
from scipy.stats import mannwhitneyu
# Loading the datasets
women_df = pd.read_csv('women_results.csv')
men_df = pd.read_csv('men_results.csv')
# Checking the top 10 rows of the datasets
print(women_df.head(10))
print(men_df.head(10))
# Filtering the dataset to only official FIFA World Cup matches from 2002-01-01
women_wc = women_df[(women_df['tournament'] == 'FIFA World Cup') & (women_df['date'] >= '2002-01-01')]
men_wc = men_df[(men_df['tournament'] == 'FIFA World Cup') & (men_df['date'] >= '2002-01-01')]
# Checking the top rows of the filtered datasets
print(women_wc.head())
print(men_wc.head())
# Calculate total goals per match
women_goals = women_wc['home_score'] + women_wc['away_score']
men_goals = men_wc['home_score'] + men_wc['away_score']
# Perform one-side independent test
u_stat, p_val = mannwhitneyu(women_goals, men_goals, alternative = 'greater')
# Interpreting the results
alpha = 0.10
results = 'reject' if p_val < alpha else 'fail to reject'
# Saving the result in a dictionary
result_dict = {
"p_val" : p_val,
"result" : results
}
print(result_dict)