CommencerCommencer gratuitement

Adding a second factor to the analysis

Even though the search rate for males is much higher than for females, it's possible that the difference is mostly due to a second factor.

For example, you might hypothesize that the search rate varies by violation type, and the difference in search rate between males and females is because they tend to commit different violations.

You can test this hypothesis by examining the search rate for each combination of gender and violation. If the hypothesis was true, you would find that males and females are searched at about the same rate for each violation. Let's find out if that's the case!

Cet exercice fait partie du cours

Analyzing Police Activity with pandas

Afficher le cours

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

# Calculate the search rate for each combination of gender and violation
print(ri.groupby(____).____)
Modifier et exécuter le code