Fisher's exact test
Now, you'll work with the Olympics dataset to look at the relative success of the American swimming and athletics teams. Whether each athlete received a medal is coded as True
or False
in the MedalTF
column of athletes
. Do a larger proportion of swimming or athletics participants come home with medals? A Fisher exact test is a useful way to compare proportions of samples falling into discrete categories. To test this, you'll need to perform a Fisher exact test on MedalTF
in relation to Sport
. pandas
and plotnine
have already been imported as pd
and p9
.
This is a part of the course
“Performing Experiments in Python”
Exercise instructions
- Using the
crosstab()
function, produce a cross-tabulation ofMedalTF
againstSport
, save the result astable
andprint()
it. - Perform a
fisher_exact()
test ontable
and print the result. - Compare the p-value to the given
alpha
and print the message.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Create a table of cross-tabulations
table = pd.crosstab(____)
print(____)
# Perform the Fisher exact test
fisher = ____(____, alternative='two-sided')
____(____)
# Is the result significant?
alpha = 0.05
if ____ < ____
print("Proportions of medal winners differ significantly")
else:
print("No significant difference in proportions of medal winners found")
This exercise is part of the course
Performing Experiments in Python
Learn about experimental design, and how to explore your data to ask and answer meaningful questions.
In this chapter, you will learn how to explore your data and ask meaningful questions. Then, you will discover how to answer these question by using your first statistical hypothesis tests: the t-test, the Chi-Square test, the Fisher exact test, and the Pearson correlation test.
Exercise 1: Welcome to the course!Exercise 2: Getting started with plotnineExercise 3: BoxplotsExercise 4: Density plotsExercise 5: Student's t-testExercise 6: Your first t-testExercise 7: One-sample t-testExercise 8: Two-sample t-testExercise 9: Testing proportion and correlationExercise 10: Chi-square testExercise 11: Fisher's exact testExercise 12: Pearson correlationWhat is DataCamp?
Learn the data skills you need online at your own pace—from non-coding essentials to data science and machine learning.