mirror of
https://github.com/jprdonnelly/538data.git
synced 2025-12-19 17:37:43 -05:00
Add obama clemency
This commit is contained in:
@@ -5,6 +5,7 @@ We hope you'll use it to check our work and to create stories and visualizations
|
||||
Article Date(s) | Headline(s) | Folder
|
||||
---|---------|-------------
|
||||
Jan. 23, 2017 | [Higher Rates Of Hate Crimes Are Tied To Income Inequality](https://fivethirtyeight.com/features/higher-rates-of-hate-crimes-are-tied-to-income-inequality/) | `hate-crimes`
|
||||
Jan. 19, 2017 | [Obama Granted Clemency Unlike Any Other President In History](https://fivethirtyeight.com/features/obama-granted-clemency-unlike-any-other-president-in-history/) | `obama-clemency`
|
||||
Dec. 16, 2016 | [The Last 10 Weeks Of 2016 Campaign Stops In One Handy Gif](http://fivethirtyeight.com/features/the-last-10-weeks-of-2016-campaign-stops-in-one-handy-gif/) | `presidential-campaign-trail`
|
||||
Oct. 6, 2016 | [A Handful Of Cities Are Driving 2016’s Rise In Murders](http://fivethirtyeight.com/features/a-handful-of-cities-are-driving-2016s-rise-in-murders/) | `murder_2016`
|
||||
Sept. 16, 2016 | [When Does Praying In Public Make Others Uncomfortable?](http://fivethirtyeight.com/features/when-does-praying-in-public-make-others-uncomfortable/) | `religion-survey`
|
||||
|
||||
7
obama-commutations/README.md
Normal file
7
obama-commutations/README.md
Normal file
@@ -0,0 +1,7 @@
|
||||
### Obama commutation data
|
||||
|
||||
The raw data behind the story [Obama Granted Clemency Unlike Any Other President In History](https://fivethirtyeight.com/features/obama-granted-clemency-unlike-any-other-president-in-history/)
|
||||
|
||||
The data in `obama_commutations.csv` is copied from the Justice Department website. The python script parses it by looking at the first column to figure out what is contained in the second column.
|
||||
|
||||
Source: [Department of Justice](https://www.justice.gov/pardon/obama-commutations)
|
||||
156
obama-commutations/obama_commutation_categories.ipynb
Normal file
156
obama-commutations/obama_commutation_categories.ipynb
Normal file
@@ -0,0 +1,156 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import csv \n",
|
||||
"from datetime import datetime\n",
|
||||
"from dateutil.relativedelta import relativedelta\n",
|
||||
"\n",
|
||||
"# Open the CSV file for a president\n",
|
||||
"with open('obama_commutations.csv') as csvfile:\n",
|
||||
" reader = csv.DictReader(csvfile)\n",
|
||||
" rows = [row for row in reader]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"rows\n",
|
||||
"\n",
|
||||
"# Figure out the indicies where each individual entry begins\n",
|
||||
"individualSplits = []\n",
|
||||
"\n",
|
||||
"for i, row in enumerate(rows):\n",
|
||||
" # Names don't have a key column, and the next row always has key \"Offense:\"\n",
|
||||
" try:\n",
|
||||
" if rows[i]['key'] == '' and (i == 0 or rows[i+1]['key'] == 'Offense:'):\n",
|
||||
" individualSplits.append(i)\n",
|
||||
" except:\n",
|
||||
" pass"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"individuals = []\n",
|
||||
"\n",
|
||||
"# Parse each individual into a dict with values representing the name and the offense\n",
|
||||
"for i, split in enumerate(individualSplits):\n",
|
||||
" try:\n",
|
||||
" nextSplit = individualSplits[i + 1]\n",
|
||||
" except: \n",
|
||||
" nextSplit = len(rows)\n",
|
||||
" \n",
|
||||
" individual = {\n",
|
||||
" 'name': '',\n",
|
||||
" 'offense': '',\n",
|
||||
" }\n",
|
||||
" \n",
|
||||
" individual['name'] += rows[split]['info']\n",
|
||||
" \n",
|
||||
" for x in range(split + 1, nextSplit):\n",
|
||||
" \n",
|
||||
" if rows[x]['key'] == 'Offense:' or (rows[x]['key'] == '' and rows[x - 1]['key'] == 'Offense:'):\n",
|
||||
" individual['offense'] += rows[x]['info']\n",
|
||||
" \n",
|
||||
" individuals.append(individual)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"drug_words = [\n",
|
||||
" \"cocaine\",\n",
|
||||
" \"marijuana\",\n",
|
||||
" \"controlled substance\",\n",
|
||||
" \"drug\",\n",
|
||||
" \"distribute\",\n",
|
||||
" \"distribution\",\n",
|
||||
" \"heroin\",\n",
|
||||
" \"LSD\",\n",
|
||||
" \"manufacture\",\n",
|
||||
"]\n",
|
||||
"\n",
|
||||
"offenses = {\n",
|
||||
" 'drug': 0,\n",
|
||||
" 'conspiracy': 0\n",
|
||||
"}\n",
|
||||
"\n",
|
||||
"for person in individuals:\n",
|
||||
" \n",
|
||||
" crime = person['offense'].lower()\n",
|
||||
" \n",
|
||||
" if any(word in crime for word in drug_words):\n",
|
||||
" offenses['drug'] += 1\n",
|
||||
" \n",
|
||||
" if \"conspiracy\" in crime:\n",
|
||||
" offenses['conspiracy'] += 1\n",
|
||||
"\n",
|
||||
"offenses['drug'] = offenses['drug'] / len(individuals)\n",
|
||||
"offenses['conspiracy'] = offenses['conspiracy'] / len(individuals)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"{'conspiracy': 0.6227371469949312, 'drug': 0.9840695148443157}\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"print(offenses)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"anaconda-cloud": {},
|
||||
"kernelspec": {
|
||||
"display_name": "Python [default]",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.5.2"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 1
|
||||
}
|
||||
7078
obama-commutations/obama_commutations.csv
Normal file
7078
obama-commutations/obama_commutations.csv
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user