LoslegenKostenlos loslegen

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.

Diese Übung ist Teil des Kurses

Foundations of Inference in Python

Kurs anzeigen

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

# 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)
Code bearbeiten und ausführen