Python Analysing Police Activity with Pandas

 # Create a DataFrame of female drivers stopped for speeding

female_and_speeding = ri[(ri.driver_gender == 'F') & (ri.violation == 'Speeding')]


# Create a DataFrame of male drivers stopped for speeding

male_and_speeding = ri[(ri.driver_gender == 'M') & (ri.violation == 'Speeding')]


# Compute the stop outcomes for female drivers (as proportions)

print(female_and_speeding.stop_outcome.value_counts(normalize=True))


# Compute the stop outcomes for male drivers (as proportions)

print(male_and_speeding.stop_outcome.value_counts(normalize=True))

Comments

Popular posts from this blog

Binomial Test in Python

Python Syntax and Functions Part2 (Summary Statistics)

Slicing and Indexing in Python Pandas