There are a bunch of different ways we might think about the example of the application from the fake data from yesterday. We saw a test where the null hypothesis was that the application offering rate for black renters is equal to the overall application offering rate. With that hypothesis, we saw a binomial test, and here's a slightly more filled out version of that test.
import pandas as pd from scipy.stats import binom_test df = pd.read_csv("classdata/simulated_housing_test.csv")
# looking to refresh our memory of the names of variables and such df.head()
general_prob_app = df.application.value_counts() / len(df)
number_black_app_offered = df[df.race == 'black'].application.value_counts() number_black_testers = len(df[df.race == 'black']) p = binom_test(number_black_app_offered, number_black_testers, general_prob_app)