Add files via upload
This commit is contained in:
parent
61dc724159
commit
49aa431222
@ -6,7 +6,7 @@
|
|||||||
"source": [
|
"source": [
|
||||||
"# Tracking Trump: Electoral Votes\n",
|
"# Tracking Trump: Electoral Votes\n",
|
||||||
"\n",
|
"\n",
|
||||||
"[Morning Consult](https://morningconsult.com) has a page called [Tracking Trump](https://morningconsult.com/tracking-trump/) that summarizes the presidential approval polls on a state-by-state basis, and tells you how many states Trump has a net positive or net negative approval rating. But I don't care about the number of *states*; I care about the number of *electoral votes*. This notebook computes that for me:"
|
"[Morning Consult](https://morningconsult.com) has a page called [Tracking Trump](https://morningconsult.com/tracking-trump/) that summarizes the presidential approval polls on a state-by-state basis, and tells you how many states Trump has a net positive or net negative approval rating. But I don't care about the number of *states*; I care about the number of *electoral votes*. This notebook computes that for me."
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -41,10 +41,11 @@
|
|||||||
" \"How many electoral votes would Trump win today, given a swing.\"\n",
|
" \"How many electoral votes would Trump win today, given a swing.\"\n",
|
||||||
" return sum(votes[row.state] for row in rows if net(row) + swing > 0)\n",
|
" return sum(votes[row.state] for row in rows if net(row) + swing > 0)\n",
|
||||||
"\n",
|
"\n",
|
||||||
"votes = dict(AL=9, AK=3, AZ=11, AR=6, CA=55, CO=9, CT=7, DE=3, DC=3, FL=29, GA=16, HI=4, ID=4,\n",
|
"votes = dict(AL=9, AK=3, AZ=11, AR=6, CA=55, CO=9, CT=7, DE=3, DC=3, FL=29, \n",
|
||||||
" IL=20, IN=11, IA=6, KS=6, KY=8, LA=8, ME=4, MD=10, MA=11, MI=16, MN=10, MS=6, MO=10, \n",
|
" GA=16, HI=4, ID=4, IL=20, IN=11, IA=6, KS=6, KY=8, LA=8, ME=4, \n",
|
||||||
" MT=3, NE=5, NV=6, NH=4, NJ=14, NM=5, NY=29, NC=15, ND=3, OH=18, OK=7, OR=7, PA=20, \n",
|
" MD=10, MA=11, MI=16, MN=10, MS=6, MO=10, MT=3, NE=5, NV=6, NH=4, \n",
|
||||||
" RI=4, SC=9, SD=3, TN=11, TX=38, UT=6, VT=3, VA=13, WA=12, WV=5, WI=10, WY=3)"
|
" NJ=14, NM=5, NY=29, NC=15, ND=3, OH=18, OK=7, OR=7, PA=20, RI=4, \n",
|
||||||
|
" SC=9, SD=3, TN=11, TX=38, UT=6, VT=3, VA=13, WA=12, WV=5, WI=10, WY=3)"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -71,9 +72,9 @@
|
|||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"source": [
|
"source": [
|
||||||
"What that says is that if an election were held today, January 23, 2019, and if Trump won those states in which he has a net positive approval (i.e. more approval than disapproval), **he would get 164 electoral votes** (that's 9 worse than McCain in 2008). You need **270** to win.\n",
|
"This says that Trump has a net positive approval (i.e. more approval than disapproval) in states with a total of **164** electoral votes. You need **270** to win.\n",
|
||||||
"\n",
|
"\n",
|
||||||
"But things can change. The election is a long ways away, and we don't know who's running, and we don't know if there is systematic bias in the polling data. In the table below, I list the number of electoral votes Trump would get assuming he gets an increase of net approval of 0 to 9 percentage points across the board in every state. We see he would need a **7** percent upswing in order to win."
|
"But of course these are approval polls, not ballots, and don't translate directly to votes. Things can change; the election is a long ways away, we don't know who's running, we don't know if there are third party candidate(s), and we don't know if there is systematic bias in the polling data. In the table below, I list the number of electoral votes Trump would get assuming he gets an increase of net approval of 0 to 9 percentage points across the board in every state. We see he would need a **7** percent upswing from the polling data in order to win."
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -118,69 +119,97 @@
|
|||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
"data": {
|
"name": "stdout",
|
||||||
"text/plain": [
|
"output_type": "stream",
|
||||||
"[(-62, 'DC', 3),\n",
|
"text": [
|
||||||
" (-31, 'VT', 3),\n",
|
"DC: 3 EV, net -62 (+17 -79 ?4)\n",
|
||||||
" (-29, 'CA', 55),\n",
|
"VT: 3 EV, net -31 (+33 -64 ?3)\n",
|
||||||
" (-29, 'MA', 11),\n",
|
"CA: 55 EV, net -29 (+33 -62 ?5)\n",
|
||||||
" (-28, 'HI', 4),\n",
|
"MA: 11 EV, net -29 (+33 -62 ?5)\n",
|
||||||
" (-28, 'MD', 10),\n",
|
"HI: 4 EV, net -28 (+34 -62 ?4)\n",
|
||||||
" (-23, 'NY', 29),\n",
|
"MD: 10 EV, net -28 (+34 -62 ?4)\n",
|
||||||
" (-23, 'WA', 12),\n",
|
"NY: 29 EV, net -23 (+36 -59 ?5)\n",
|
||||||
" (-22, 'OR', 7),\n",
|
"WA: 12 EV, net -23 (+36 -59 ?5)\n",
|
||||||
" (-21, 'IL', 20),\n",
|
"OR: 7 EV, net -22 (+37 -59 ?4)\n",
|
||||||
" (-20, 'CT', 7),\n",
|
"IL: 20 EV, net -21 (+37 -58 ?5)\n",
|
||||||
" (-19, 'NM', 5),\n",
|
"CT: 7 EV, net -20 (+38 -58 ?4)\n",
|
||||||
" (-19, 'RI', 4),\n",
|
"NM: 5 EV, net -19 (+38 -57 ?5)\n",
|
||||||
" (-18, 'NJ', 14),\n",
|
"RI: 4 EV, net -19 (+38 -57 ?5)\n",
|
||||||
" (-16, 'CO', 9),\n",
|
"NJ: 14 EV, net -18 (+39 -57 ?4)\n",
|
||||||
" (-16, 'DE', 3),\n",
|
"CO: 9 EV, net -16 (+40 -56 ?4)\n",
|
||||||
" (-14, 'MN', 10),\n",
|
"DE: 3 EV, net -16 (+40 -56 ?4)\n",
|
||||||
" (-12, 'MI', 16),\n",
|
"MN: 10 EV, net -14 (+41 -55 ?4)\n",
|
||||||
" (-12, 'WI', 10),\n",
|
"MI: 16 EV, net -12 (+41 -53 ?6)\n",
|
||||||
" (-11, 'NV', 6),\n",
|
"WI: 10 EV, net -12 (+42 -54 ?4)\n",
|
||||||
" (-10, 'IA', 6),\n",
|
"NV: 6 EV, net -11 (+42 -53 ?5)\n",
|
||||||
" (-8, 'AZ', 11),\n",
|
"IA: 6 EV, net -10 (+43 -53 ?4)\n",
|
||||||
" (-8, 'NH', 4),\n",
|
"AZ: 11 EV, net -8 (+44 -52 ?4)\n",
|
||||||
" (-6, 'ME', 4),\n",
|
"NH: 4 EV, net -8 (+44 -52 ?4)\n",
|
||||||
" (-6, 'PA', 20),\n",
|
"ME: 4 EV, net -6 (+45 -51 ?4)\n",
|
||||||
" (-3, 'FL', 29),\n",
|
"PA: 20 EV, net -6 (+45 -51 ?4)\n",
|
||||||
" (-3, 'GA', 16),\n",
|
"FL: 29 EV, net -3 (+46 -49 ?5)\n",
|
||||||
" (-3, 'NC', 15),\n",
|
"GA: 16 EV, net -3 (+46 -49 ?5)\n",
|
||||||
" (-3, 'OH', 18),\n",
|
"NC: 15 EV, net -3 (+46 -49 ?5)\n",
|
||||||
" (-3, 'VA', 13),\n",
|
"OH: 18 EV, net -3 (+46 -49 ?5)\n",
|
||||||
" (2, 'KS', 6),\n",
|
"VA: 13 EV, net -3 (+46 -49 ?5)\n",
|
||||||
" (3, 'MO', 10),\n",
|
"KS: 6 EV, net +2 (+49 -47 ?4)\n",
|
||||||
" (3, 'UT', 6),\n",
|
"MO: 10 EV, net +3 (+49 -46 ?5)\n",
|
||||||
" (4, 'AK', 3),\n",
|
"UT: 6 EV, net +3 (+49 -46 ?5)\n",
|
||||||
" (4, 'MT', 3),\n",
|
"AK: 3 EV, net +4 (+49 -45 ?6)\n",
|
||||||
" (4, 'TX', 38),\n",
|
"MT: 3 EV, net +4 (+50 -46 ?4)\n",
|
||||||
" (8, 'IN', 11),\n",
|
"TX: 38 EV, net +4 (+49 -45 ?6)\n",
|
||||||
" (8, 'NE', 5),\n",
|
"IN: 11 EV, net +8 (+52 -44 ?4)\n",
|
||||||
" (9, 'ND', 3),\n",
|
"NE: 5 EV, net +8 (+52 -44 ?4)\n",
|
||||||
" (9, 'SC', 9),\n",
|
"ND: 3 EV, net +9 (+52 -43 ?5)\n",
|
||||||
" (11, 'AR', 6),\n",
|
"SC: 9 EV, net +9 (+52 -43 ?5)\n",
|
||||||
" (11, 'ID', 4),\n",
|
"AR: 6 EV, net +11 (+53 -42 ?5)\n",
|
||||||
" (13, 'LA', 8),\n",
|
"ID: 4 EV, net +11 (+53 -42 ?5)\n",
|
||||||
" (13, 'OK', 7),\n",
|
"LA: 8 EV, net +13 (+54 -41 ?5)\n",
|
||||||
" (15, 'KY', 8),\n",
|
"OK: 7 EV, net +13 (+54 -41 ?5)\n",
|
||||||
" (15, 'SD', 3),\n",
|
"KY: 8 EV, net +15 (+55 -40 ?5)\n",
|
||||||
" (16, 'TN', 11),\n",
|
"SD: 3 EV, net +15 (+55 -40 ?5)\n",
|
||||||
" (17, 'MS', 6),\n",
|
"TN: 11 EV, net +16 (+56 -40 ?4)\n",
|
||||||
" (21, 'AL', 9),\n",
|
"MS: 6 EV, net +17 (+56 -39 ?5)\n",
|
||||||
" (26, 'WV', 5),\n",
|
"AL: 9 EV, net +21 (+58 -37 ?5)\n",
|
||||||
" (32, 'WY', 3)]"
|
"WV: 5 EV, net +26 (+61 -35 ?4)\n",
|
||||||
|
"WY: 3 EV, net +32 (+64 -32 ?4)\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"def undecided(row): return 100 - row.app - row.dis\n",
|
||||||
|
"\n",
|
||||||
|
"for r in sorted(rows, key=net):\n",
|
||||||
|
" print('{}: {:2d} EV, net {:+3d} (+{} -{} ?{})'\n",
|
||||||
|
" .format(r.state, votes[r.state], net(r), r.app, r.dis, undecided(r)))"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"execution_count": 4,
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"Here are all the states with more than 5% undecided. This is evidence that most people have made up their mind."
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 5,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"data": {
|
||||||
|
"text/plain": [
|
||||||
|
"{'AK': 6, 'MI': 6, 'TX': 6}"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"execution_count": 5,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"output_type": "execute_result"
|
"output_type": "execute_result"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"source": [
|
"source": [
|
||||||
"sorted((net(row), row.state, votes[row.state]) \n",
|
"{r.state: undecided(r)\n",
|
||||||
" for row in rows)"
|
" for r in rows if undecided(r) > 5}"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
Loading…
Reference in New Issue
Block a user