Comparing violations by gender
The question we're trying to answer is whether male and female drivers tend to commit different types of traffic violations.
In this exercise, you'll first create a DataFrame for each gender, and then analyze the violations in each DataFrame separately.
แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร
Analyzing Police Activity with pandas
คำแนะนำการฝึกหัด
- Create a DataFrame,
female, that only contains rows in whichdriver_genderis'F'. - Create a DataFrame,
male, that only contains rows in whichdriver_genderis'M'. - Count the violations committed by female drivers and express them as proportions.
- Count the violations committed by male drivers and express them as proportions.
แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ
ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์
# Create a DataFrame of female drivers
female = ri[____]
# Create a DataFrame of male drivers
male = ri[____]
# Compute the violations by female drivers (as proportions)
print(female.____)
# Compute the violations by male drivers (as proportions)
print(male.____)