# Calculating the number of people killed according to race
race_counts = data[‘race’].value_counts()
# Calculating the proportion of people killed according to race
race_proportions = race_counts / len(data)
race_proportions_sorted = race_proportions.sort_values(ascending=False)
race_proportions_sorted
us_population_proportions = {
‘W’: 0.62, # White
‘H’: 0.19, # Hispanic
‘B’: 0.13, # Black
‘A’: 0.055, # Asian
‘N’: 0.01, # Native American
‘O’: 0.025, # Other
‘Unknown’: 0 # Unknown (we’ll assume 0 since we don’t have data for this)
}
# Convert the U.S. population proportions dictionary to a Series for correct operations
us_population_proportions_series = pd.Series(us_population_proportions)
# Calculate the proportion of individuals shot by race relative to their estimated population percentage
shooting_proportion_relative = race_proportions / us_population_proportions_series
shooting_proportion_relative_sorted = shooting_proportion_relative.sort_values(ascending=False)
shooting_proportion_relative_sorted
result:
B 1.697653
N 1.312172
H 0.766914
W 0.665156
A 0.293109
O 0.094976
Unknown NaN
dtype: float64
conclusion:
Here are the proportions of individuals shot by race relative to their estimated population percentage in the U.S.:
Black (B): The proportion of Black individuals shot is approximately 1.70 times their representation in the U.S. population.
Native American (N): The proportion of Native American individuals shot is approximately 1.31 times their representation in the U.S. population. Hispanic (H): The proportion of Hispanic individuals shot is approximately 0.77 times their representation in the U.S. population. White (W): The proportion of White individuals shot is approximately 0.67 times their representation in the U.S. population. Asian (A): The proportion of Asian individuals shot is approximately 0.29 times their representation in the U.S. population. Other (O): The proportion of individuals from other racial categories shot is approximately 0.09 times their representation in the U.S. population
