ComeçarComece de graça

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!

Este exercício faz parte do curso

Analyzing Police Activity with pandas

Ver curso

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

# Calculate the search rate for each combination of gender and violation
print(ri.groupby(____).____)
Editar e executar o código