<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Observations
Date of death
There is no significan difference between years 2012, 2013 and 2014.
There is correlation between months within year. Lowers death counts is in february for each year. Highest deat count is in summer.
Gender
Much more men have died by gun than women.
Race
Mostly white people died by gun. However distribution by race is not considered.
Step1:  Death by race
We have learned that black people are much more likely to get killed by gun than people of other races.
For deth rate by race, it could be interesting to evaluate other kinds of death types by race.
Other steps
There are many things to explore in this data set. It is (sadly) interesting set because of recent development in United States.
<ASSISTANT_TASK:>
Python Code:
census = list(csv.reader(open("census.csv", 'r')))
for index, column in enumerate(census[0]):
    print("{} - {}: {}".format(index, column, census[1][index]))
def get_race_count(census, column_indexes):
    return sum([int(census[1][index]) for index in column_indexes])
race_percentage = {
    "Black": get_race_count(census, [12]),
    "Asian/Pacific Islander": get_race_count(census, [14, 15]),
    "White": get_race_count(census, [10]),
    "Hispanic": get_race_count(census, [11]),
    "Native American/Native Alaskan": get_race_count(census, [13])
}
race_rate_by_100k = {}
for key in race_counts:
    race_rate_by_100k[key] = float(race_counts[key]) / race_percentage[key] * 100000
    
plot_counts(race_rate_by_100k, "race rate by 100 000")
homicide_by_race_counts = extract_counts([row for row in data if row[3] == 'Homicide'],
                                        lambda row: row[7])
plot_counts(homicide_by_race_counts, "race (homicides)")
set([row[3] for row in data])
homicide_by_race_rate_by_100k = {}
for key in homicide_by_race_counts:
    homicide_by_race_rate_by_100k[key] = float(homicide_by_race_counts[key]) / race_percentage[key] * 100000
    
plot_counts(homicide_by_race_rate_by_100k, "race rate by 100 000 (homicide)")
Explanation: Observations
Date of death
There is no significan difference between years 2012, 2013 and 2014.
There is correlation between months within year. Lowers death counts is in february for each year. Highest deat count is in summer.
Gender
Much more men have died by gun than women.
Race
Mostly white people died by gun. However distribution by race is not considered.
End of explanation
for death_type in set([row[3] for row in data]):
    race_counts = extract_counts([row for row in data if row[3] == death_type],
                                 lambda row: row[7])
    plot_counts(race_counts, "race (%s)" % death_type)
    
    race_rate_by_100k = {}
    for key in race_counts:
        race_rate_by_100k[key] = float(race_counts[key]) / race_percentage[key] * 100000
    
    plot_counts(race_rate_by_100k, "race rate by 100 000 (%s)" % death_type)
Explanation: Death by race
We have learned that black people are much more likely to get killed by gun than people of other races.
For deth rate by race, it could be interesting to evaluate other kinds of death types by race.
Other steps
There are many things to explore in this data set. It is (sadly) interesting set because of recent development in United States.
End of explanation
<END_TASK>