Effect size for categorical variables
You saw in the City of Austin employee data that job titles have an unequal distribution of genders. But does the same thing hold for ethnicities? And to what extent does ethnicity relate to the job title chosen? In this exercise you'll dig in and answer that question.
A DataFrame of comparing job titles and ethnicities (employees_df) has been loaded for you, as have the packages pandas as pd, NumPy as np, and stats from SciPy.
本练习是课程的一部分
Foundations of Inference in Python
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Compute the chi-squared statistic
chi2, p, d, expected = stats.____(____)
# Compute the DOF using the number of rows and columns
dof = min(____.shape[0] - 1, ____.shape[1] - 1)
# Compute the total number of people
n = np.sum(____.values)
# Compute Cramer's V
v = np.____((____ / ____) / ____)
print("Cramer's V:", v, "\nDegrees of freedom:", dof)