Session Ready
Exercise

Determine the Arrests by District by Year

Using your crimes_by_district dictionary from the previous exercise, you'll now determine the number arrests in each City district for each year. Counter is already imported for you. You'll want to use the IPython Shell to explore the crimes_by_district dictionary to determine how to check if an arrest was made.

Instructions
100 XP
  • Loop over the crimes_by_district dictionary, unpacking it into the variables district and crimes.
    • Create an empty Counter object called year_count.
    • Loop over the crimes:
      • If there was an arrest,
        • Convert crime['Date'] to a datetime object called year.
        • Add the crime to the Counter for the year, by using year as the key of year_count.
    • Print the Counter. This has been done for you, so hit 'Submit Answer' to see the result!