Get startedGet started for free

Testing sample size

In order to conduct a hypothesis test and be sure that the result is fair, a sample must meet three requirements: it is a random sample of the population, the observations are independent, and there are enough observations. Of these, only the last condition is easily testable with code.

The minimum sample size depends on the type of hypothesis tests you want to perform. You'll now test some scenarios on the late_shipments dataset.

Note that the .all() method from pandas can be used to check if all elements are true. For example, given a DataFrame df with numeric entries, you check to see if all its elements are less than 5, using (df < 5).all().

late_shipments is available, and pandas is loaded as pd.

This exercise is part of the course

Hypothesis Testing in Python

View Course

Hands-on interactive exercise

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

# Count the freight_cost_group values
counts = ____

# Print the result
print(counts)

# Inspect whether the counts are big enough
print((counts >= ____).all())
Edit and Run Code