1. Learn
  2. /
  3. Courses
  4. /
  5. Hypothesis Testing in Python

Connected

Exercise

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.

Instructions 1/4

undefined XP
  • 1
    • Get the count of each value in the freight_cost_group column of late_shipments.
    • Insert a suitable number to inspect whether the counts are "big enough" for a two sample t-test.
  • 2
    • Get the count of each value in the late column of late_shipments.
    • Insert a suitable number to inspect whether the counts are "big enough" for a one sample proportion test.
  • 3
    • Get the count of each value in the freight_cost_group column of late_shipments grouped by vendor_inco_term.
    • Insert a suitable number to inspect whether the counts are "big enough" for a chi-square independence test.
  • 4
    • Get the count of each value in the shipment_mode column of late_shipments.
    • Insert a suitable number to inspect whether the counts are "big enough" for an ANOVA test.