Skip to content

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.

# Start your code here!
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
import pingouin
# Load csv files and parsing the date column
men_results = pd.read_csv('men_results.csv', parse_dates=['date'])
women_results = pd.read_csv('women_results.csv', parse_dates=['date'])
# Viewing mens column names, data types and values
men_results.info()
men_results.value_counts()
# Viewing womens column names, data types and values
women_results.info()
women_results.value_counts()
women_results.value_counts('tournament', ascending=False)
men_results.value_counts('tournament', ascending=False)
# Filtering for FIFA World Cup Matches
men_fifa = men_results[(men_results['tournament'].isin(['FIFA World Cup'])) & (men_results['date'] > '2002-01-01')]
women_fifa = women_results[(women_results['tournament'].isin(['FIFA World Cup'])) & (women_results['date'] > '2002-01-01')]
print([men_fifa, women_fifa])
men_fifa.head()
women_fifa.head()
# Creating gender groups and number of goals scored column as per hypothesis
men_fifa['group'] = 'men'
men_fifa['goals_scored'] = men_fifa['home_score'] + men_fifa['away_score']
women_fifa['group'] = 'women'
women_fifa['goals_scored'] = women_fifa['home_score'] + women_fifa['away_score']

men_fifa.head()
women_fifa.head()
# Checking to see if the men's score data is normally distributed.
men_fifa['goals_scored'].hist()
plt.show()
plt.clf()

# Data shows that it is not normally distributed
# Checking to see if the women's score data is normally distributed.
women_fifa['goals_scored'].hist()
plt.show()
plt.clf()

# Data is not normally distributed. Both histograms show a right tailed distribution.

Since none of the data are normally distributed, we'll use the Wilcoxon-Mann-Whitney test to test the hypothesis.