Created
June 24, 2015 20:22
-
-
Save phillipsm/29d4cb4addb5c5a21ae7 to your computer and use it in GitHub Desktop.
Sum and print aggregations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
inmate_cities = {} | |
for inmate in inmates: | |
if inmate['city'] in inmate_cities: | |
inmate_cities[inmate['city']] += 1 | |
else: | |
inmate_cities[inmate['city']] = 1 | |
print inmate_cities | |
inmate_races = {} | |
for inmate in inmates: | |
if inmate['race'] in inmate_races: | |
inmate_races[inmate['race']] += 1 | |
else: | |
inmate_races[inmate['race']] = 1 | |
print inmate_races |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment