Get startedGet started for free

One-way ANOVA

Let's have another look at some data from our Olympic dataset. How does the Weight of athletes vary between teams from different countries? In this exercise, you're going to use a one-way ANOVA to check for the presence of significant variation in Weight of Olympic athletes. You have been provided with the athletes DataFrame, containing details about male athletes from the Team of the United States, France, and China. Here is a set of boxplots of Weight for the athletes from those three countries.

Density plot of the body weights of Olympic athletes from three competing countries

A one-way ANOVA will allow you to see whether any differences between these groups of values are significant. pandas, scipy.stats, and plotnine have been loaded into the workspace as pd, stats, and p9, respectively.

This exercise is part of the course

Performing Experiments in Python

View Course

Exercise instructions

  • Create three arrays, France_athletes, US_athletes, and China_athletes, for the athletes' Weights from each country.
  • Using f_oneway(), perform a one-way ANOVA on the arrays, save the result as anova, and print it.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Create arrays
France_athletes = athletes[athletes.Team == ____].Weight
US_athletes = athletes[____].____
China_athletes = ____

# Perform one-way ANOVA
anova = stats.f_oneway(____)
print(____)
Edit and Run Code