Get startedGet started for free

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!

This exercise is part of the course

Analyzing Police Activity with pandas

View Course

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Calculate the search rate for each combination of gender and violation
print(ri.groupby(____).____)
Edit and Run Code