Skip to content

Instantly share code, notes, and snippets.

@phillipsm
Created June 24, 2015 20:22
Show Gist options
  • Save phillipsm/29d4cb4addb5c5a21ae7 to your computer and use it in GitHub Desktop.
Save phillipsm/29d4cb4addb5c5a21ae7 to your computer and use it in GitHub Desktop.
Sum and print aggregations
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