Skip to content

Instantly share code, notes, and snippets.

@frankamp
Created November 6, 2012 20:42
Show Gist options
  • Save frankamp/4027383 to your computer and use it in GitHub Desktop.
Save frankamp/4027383 to your computer and use it in GitHub Desktop.
vote worth
We can make this file beautiful and searchable if this error is corrected: It looks like row 59 should actually have 31 columns, instead of 6. in line 58.
SUMLEV,REGION,DIVISION,STATE,NAME,CENSUS2010POP,ESTIMATESBASE2010,POPESTIMATE2010,POPESTIMATE2011,NPOPCHG_2010,NPOPCHG_2011,BIRTHS2010,BIRTHS2011,DEATHS2010,DEATHS2011,NATURALINC2010,NATURALINC2011,INTERNATIONALMIG2010,INTERNATIONALMIG2011,DOMESTICMIG2010,DOMESTICMIG2011,NETMIG2010,NETMIG2011,RESIDUAL2010,RESIDUAL2011,RBIRTH2011,RDEATH2011,RNATURALINC2011,RINTERNATIONALMIG2011,RDOMESTICMIG2011,RNETMIG2011
10,0,0,0,United States,308745538,308745538,309330219,311591917,584681,2261698,990000,4008000,595786,2450126,394214,1557874,190467,703824,0,0,190467,703824,0,0,12.90983126,7.891894516,5.017936742,2.267028212,0,2.267028212
20,1,0,0,Northeast Region,55317240,55317244,55366108,55521598,48864,155490,161044,644052,112828,457744,48216,186308,36987,143923,-35356,-173113,1631,-29190,-983,-1628,11.61629225,8.255991877,3.360300375,2.595833302,-3.122311864,-0.526478562
20,2,0,0,Midwest Region,66927001,66926987,66976458,67158835,49471,182377,211730,844948,138684,570171,73046,274777,22995,86892,-46160,-178994,-23165,-92102,-410,-298,12.59844417,8.501431461,4.097012708,1.295587434,-2.668857629,-1.373270195
20,3,0,0,South Region,114555744,114555757,114857529,116046736,301772,1189207,375655,1534432,228433,944407,147222,590025,74318,262273,79590,334425,153908,596698,642,2484,13.29063368,8.18007411,5.110559565,2.271703383,2.896655027,5.16835841
20,4,0,0,West Region,71945553,71945550,72130124,72864748,184574,734624,241571,984568,115841,477804,125730,506764,56167,210736,1926,17682,58093,228418,751,-558,13.58072857,6.590633081,6.990095484,2.906806249,0.243898281,3.15070453
40,3,6,1,Alabama,4779736,4779735,4785401,4802740,5666,17339,14482,59866,11562,47768,2920,12098,1487,4461,1278,696,2765,5157,-19,84,12.48750931,9.96397529,2.52353402,0.930524489,0.145179342,1.07570383
40,4,9,2,Alaska,710231,710231,714146,722718,3915,8572,2834,11193,647,3338,2187,7855,542,1101,1139,-399,1681,702,47,15,15.57976259,4.646229567,10.93353303,1.53250412,-0.555376153,0.977127968
40,4,8,4,Arizona,6392017,6392013,6413158,6482505,21145,69347,20900,87887,11164,45899,9736,41988,5199,20542,6090,7060,11289,27602,120,-243,13.63047406,7.118517288,6.511956772,3.185877298,1.094941765,4.280819063
40,3,7,5,Arkansas,2915918,2915921,2921588,2937979,5667,16391,9218,38156,6759,28478,2459,9678,951,3178,2244,3480,3195,6658,13,55,13.02348791,9.720172156,3.303315757,1.084721789,1.187801078,2.272522867
40,4,9,6,California,37253956,37253956,37338198,37691912,84242,353714,123173,508069,57867,234045,65306,274024,33518,130927,-15021,-50684,18497,80243,439,-553,13.54306958,6.238695372,7.304374204,3.489985554,-1.351030939,2.138954614
40,4,8,8,Colorado,5029196,5029196,5047692,5116796,18496,69104,16453,66213,7350,31123,9103,35090,2907,8797,6255,24940,9162,33737,231,277,13.0283001,6.123869692,6.904430405,1.730928307,4.907281114,6.638209421
40,1,1,9,Connecticut,3574097,3574097,3575498,3580709,1401,5211,9241,37319,6855,28244,2386,9075,2479,9735,-3355,-13493,-876,-3758,-109,-106,10.42982686,7.893567081,2.536259781,2.720715038,-3.770992091,-1.050277053
40,3,5,10,Delaware,897934,897934,899792,907135,1858,7343,2774,11172,1898,7633,876,3539,578,1877,403,1944,981,3821,1,-17,12.36574582,8.44859809,3.917147732,2.077560411,2.151719466,4.229279877
40,3,5,11,District of Columbia,601723,601723,604912,617996,3189,13084,2232,9003,1098,4773,1134,4230,598,1862,1427,6907,2025,8769,30,85,14.72392036,7.80598377,6.917936591,3.045200457,11.29602554,14.341226
40,3,5,12,Florida,18801310,18801311,18838613,19057542,37302,218929,51537,213292,42097,171257,9440,42035,18142,68295,10417,108339,28559,176634,-697,260,11.25665651,9.038225646,2.218430867,3.604323447,5.717677691,9.322001137
40,3,5,13,Georgia,9687653,9687660,9712157,9815210,24497,103053,32410,134442,16640,70688,15770,63754,6509,22947,1877,15849,8386,38796,341,503,13.76959833,7.23989056,6.529707769,2.35024005,1.62326032,3.97350037
40,4,9,15,Hawaii,1360301,1360301,1363359,1374810,3058,11451,4600,18501,2241,9730,2359,8771,1602,4214,-861,-1459,741,2755,-42,-75,13.51340987,7.10693898,6.406470894,3.077969256,-1.065675639,2.012293617
40,4,8,16,Idaho,1567582,1567582,1571102,1584985,3520,13883,5789,22954,2545,11275,3244,11679,611,2074,-318,62,293,2136,-17,68,14.54586011,7.144923445,7.400936666,1.314285696,0.039289158,1.353574854
40,2,3,17,Illinois,12830632,12830632,12841980,12869257,11348,27277,42060,167000,24484,100651,17576,66349,6822,27233,-13006,-66452,-6184,-39219,-44,147,12.99042905,7.829339366,5.161089682,2.118373379,-5.169101743,-3.050728364
40,2,3,18,Indiana,6483802,6483800,6490622,6516922,6822,26300,21286,84732,14122,56499,7164,28233,2011,7175,-2353,-9059,-342,-1884,0,-49,13.02813198,8.687112648,4.341019335,1.103205955,-1.392884006,-0.289678051
40,2,4,19,Iowa,3046355,3046350,3050202,3062309,3852,12107,9400,38324,6433,27895,2967,10429,849,3150,95,-1456,944,1694,-59,-16,12.53952754,9.127181939,3.412345597,1.030672992,-0.476399961,0.554273031
40,2,4,20,Kansas,2853118,2853118,2859143,2871238,6025,12095,9845,40132,5459,24038,4386,16094,1326,4237,324,-8252,1650,-4015,-11,16,14.00674754,8.389669029,5.617078515,1.478784744,-2.880087729,-1.401302985
40,3,6,21,Kentucky,4339367,4339362,4347223,4369356,7861,22133,13991,56447,10486,41945,3505,14502,1458,4845,2920,2841,4378,7686,-22,-55,12.95164078,9.624188572,3.327452203,1.11167466,0.651861241,1.763535901
40,3,7,22,Louisiana,4533372,4533372,4545343,4574836,11971,29493,15571,63969,9771,40780,5800,23189,1354,3740,4706,2379,6060,6119,111,185,14.02801414,8.942806934,5.085207209,0.820159341,0.521700287,1.341859628
40,1,1,23,Maine,1328361,1328361,1327379,1328188,-982,809,3186,12868,3290,12688,-104,180,225,594,-1072,72,-847,666,-31,-37,9.691338987,9.555774718,0.135564269,0.447362089,0.054225708,0.501587797
40,3,5,24,Maryland,5773552,5773552,5785681,5828289,12129,42608,18102,72995,10563,43606,7539,29389,4493,16435,130,-3124,4623,13311,-33,-92,12.5702064,7.509232416,5.060973982,2.830212236,-0.537972803,2.292239432
40,1,1,25,Massachusetts,6547629,6547629,6555466,6587536,7837,32070,18589,73368,12958,52355,5631,21013,4906,19664,-2587,-8299,2319,11365,-113,-308,11.1645726,7.966977407,3.197595192,2.992314846,-1.262877385,1.72943746
40,2,3,26,Michigan,9883640,9883635,9877143,9876187,-6492,-956,28932,113894,21459,86988,7473,26906,2817,12399,-16903,-40331,-14086,-27932,121,70,11.5316253,8.807426393,2.724198907,1.25538327,-4.083463396,-2.828080126
40,2,4,27,Minnesota,5303925,5303925,5310658,5344861,6733,34203,16979,68088,9326,38436,7653,29652,2463,9417,-3354,-4719,-891,4698,-29,-147,12.77985615,7.214289609,5.565566539,1.76753474,-0.885738179,0.88179656
40,3,6,28,Mississippi,2967297,2967297,2970072,2978512,2775,8440,9515,40464,6516,28837,2999,11627,774,2385,-984,-5688,-210,-3303,-14,116,13.6045822,9.69541659,3.90916561,0.801871504,-1.912387889,-1.110516385
40,2,4,29,Missouri,5988927,5988927,5995715,6010688,6788,14973,18600,75910,13350,54361,5250,21549,1638,5319,-26,-11805,1612,-6486,-74,-90,12.64491955,9.055334891,3.589584658,0.886027231,-1.966450735,-1.080423504
40,4,8,30,Montana,989415,989415,990958,998199,1543,7241,2973,11911,1840,8629,1133,3282,128,387,310,3578,438,3965,-28,-6,11.97592749,8.676037135,3.299890356,0.389109558,3.597503867,3.986613425
40,2,4,31,Nebraska,1826341,1826341,1830141,1842641,3800,12500,6316,25991,3362,14878,2954,11113,768,2508,123,-1100,891,1408,-45,-21,14.15330395,8.101760464,6.051543489,1.365722224,-0.599000975,0.766721248
40,4,8,32,Nevada,2700551,2700551,2704283,2723322,3732,19039,9162,36772,4743,19373,4419,17399,2382,9679,-3105,-8008,-723,1671,36,-31,13.5499912,7.138691928,6.411299275,3.566582314,-2.950841117,0.615741197
40,1,1,33,New Hampshire,1316470,1316472,1316807,1318194,335,1387,3191,12795,2350,9778,841,3017,399,1165,-882,-2763,-483,-1598,-23,-32,9.711571267,7.421629062,2.289942205,0.884250139,-2.097152904,-1.212902766
40,1,2,34,New Jersey,8791894,8791894,8799593,8821155,7699,21562,25275,104343,16884,68372,8391,35971,8273,30889,-8854,-45244,-581,-14355,-111,-54,11.84319758,7.760397005,4.082800571,3.505980563,-5.135309806,-1.629329243
40,4,8,35,New Mexico,2059179,2059180,2065913,2082224,6733,16311,7109,28511,3636,15760,3473,12751,1088,3471,2135,67,3223,3538,37,22,13.74641194,7.59859185,6.147820094,1.673522355,0.032303658,1.705826013
40,1,2,36,New York,19378102,19378104,19395206,19465197,17102,69991,61126,242972,36134,146864,24992,96108,15809,64716,-23415,-90342,-7606,-25626,-284,-491,12.5048626,7.558542303,4.946320294,3.330691141,-4.64956578,-1.31887464
40,3,5,37,North Carolina,9535483,9535475,9560234,9656401,24759,96167,29777,122131,19235,78169,10542,43962,6074,18955,8092,32941,14166,51896,51,309,12.71096631,8.135555471,4.575410836,1.972769947,3.428383794,5.40115374
40,2,4,38,North Dakota,672591,672591,674629,683932,2038,9303,2280,8960,1226,5915,1054,3045,211,577,771,5597,982,6174,2,84,13.19042722,8.707742972,4.482684252,0.849428182,8.239600577,9.089028759
40,2,3,39,Ohio,11536504,11536502,11537968,11544951,1466,6983,35487,140808,26758,107668,8729,33140,2533,9186,-9670,-35198,-7137,-26012,-126,-145,12.20019011,9.328802826,2.87138728,0.795913203,-3.04970095,-2.253787747
40,3,7,40,Oklahoma,3751351,3751354,3760184,3791508,8830,31324,13366,53727,7930,34528,5436,19199,1564,4908,1738,7195,3302,12103,92,22,14.22912905,9.144440743,5.084688306,1.299841148,1.905533224,3.205374372
40,4,9,41,Oregon,3831074,3831074,3838332,3871859,7258,33527,11737,46232,7702,31451,4035,14781,1894,6604,1427,12209,3321,18813,-98,-67,11.99243962,8.158293355,3.834146262,1.713057433,3.166977316,4.880034749
40,1,2,42,Pennsylvania,12702379,12702379,12717722,12742886,15343,25164,36145,143420,30805,125152,5340,18268,4153,14714,6125,-7246,10278,7468,-275,-572,11.26603104,9.831029958,1.435001081,1.155824716,-0.569193006,0.58663171
40,1,1,44,Rhode Island,1052567,1052567,1052528,1051302,-39,-1226,2761,11012,2247,9189,514,1823,647,2040,-1184,-5089,-537,-3049,-16,0,10.46852645,8.735496689,1.73302976,1.939320192,-4.837843362,-2.89852317
40,3,5,45,South Carolina,4625364,4625364,4637106,4679230,11742,42124,14781,59522,10101,41144,4680,18378,2233,6440,4826,17187,7059,23627,3,119,12.77798482,8.832656959,3.945327863,1.382517762,3.689647947,5.07216571
40,2,4,46,South Dakota,814180,814180,816598,824082,2418,7484,2968,11763,1329,6772,1639,4991,157,533,646,1964,803,2497,-24,-4,14.33917644,8.255113733,6.084062706,0.6497306,2.394129264,3.043859863
40,3,6,47,Tennessee,6346105,6346110,6357436,6403353,11326,45917,20076,80536,14624,58883,5452,21653,2267,7608,3661,16667,5928,24275,-54,-11,12.622417,9.228739696,3.393677303,1.192402758,2.612220921,3.80462368
40,3,7,48,Texas,25145561,25145561,25253466,25674681,107905,421215,97517,396133,39836,165335,57681,230798,19258,74383,30169,115146,49427,189529,797,888,15.55654479,6.492873185,9.063671608,2.921095873,4.521900237,7.44299611
40,4,8,49,Utah,2763885,2763885,2775479,2817222,11594,41743,13153,52003,3420,14314,9733,37689,1402,5336,423,-1249,1825,4087,36,-33,18.59673886,5.118814684,13.47792417,1.908201422,-0.446653594,1.461547828
40,1,1,50,Vermont,625741,625741,625909,626431,168,522,1530,5955,1305,5102,225,853,96,406,-132,-709,-36,-303,-21,-28,9.510196911,8.147947043,1.362249868,0.648386221,-1.132280371,-0.48389415
40,3,5,51,Virginia,8001024,8001030,8023953,8096604,22923,72651,25179,101935,13937,58943,11242,42992,6379,19239,5205,10333,11584,29572,97,87,12.64658535,7.312774614,5.333810736,2.38689023,1.281965629,3.668855859
40,4,9,53,Washington,6724540,6724540,6742950,6830038,18410,87088,21833,86767,11764,48434,10069,38333,4744,17144,3626,31540,8370,48684,-29,71,12.7852467,7.136822047,5.648424651,2.526193938,4.647465982,7.173659919
40,3,5,54,West Virginia,1852994,1852996,1854368,1855364,1372,996,5127,20642,5380,21640,-253,-998,199,715,1481,1333,1680,2048,-55,-54,11.1285667,11.66661096,-0.538044258,0.385472589,0.718650296,1.104122885
40,2,3,55,Wisconsin,5686986,5686986,5691659,5711767,4673,20108,17577,69346,11376,46070,6201,23276,1400,5158,-2807,-8183,-1407,-3025,-121,-143,12.16230982,8.080027879,4.082281939,0.904640413,-1.435182725,-0.530542312
40,4,8,56,Wyoming,563626,563626,564554,568158,928,3604,1855,7555,922,4433,933,3122,150,460,-174,25,-24,485,19,-3,13.33966622,7.827232342,5.512433876,0.812209988,0.044141847,0.856351835
40,X,X,72,Puerto Rico Commonwealth,3725789,3725789,3721978,3706690,-3811,-15288,10491,42079,7224,28976,3267,13103,-7078,-28391,0,0,-7078,-28391,0,0,11.32881426,7.801129355,3.527684909,-7.643631402,0,-7.643631402
0,0,0,0,D.C.,601723
Alabama 9
Alaska 3
Arizona 11
Arkansas 6
California 55
Colorado 9
Connecticut 7
D.C. 3
Delaware 3
Florida 29
Georgia 16
Hawaii 4
Idaho 4
Illinois 20
Indiana 11
Iowa 6
Kansas 6
Kentucky 8
Louisiana 8
Maine 4
Maryland 10
Massachusetts 11
Michigan 16
Minnesota 10
Mississippi 6
Missouri 10
Montana 3
Nebraska 5
Nevada 6
New Hampshire 4
New Jersey 14
New Mexico 5
New York 29
North Carolina 15
North Dakota 3
Ohio 18
Oklahoma 7
Oregon 7
Pennsylvania 20
Rhode Island 4
South Carolina 9
South Dakota 3
Tennessee 11
Texas 38
Utah 6
Vermont 3
Virginia 13
Washington 12
West Virginia 5
Wisconsin 10
Wyoming 3
data = {}
for line in open("votes.csv"):
state,votes = line.strip().split(",")
data[state] = {"votes": int(votes), "pop": 0}
for line in open("pop.csv"):
state = line.strip().split(",")[4]
pop = line.strip().split(",")[5]
if state in data:
data[state]["pop"] = int(pop)
totalpop = 0
totalvotes = 0
for state,stats in data.iteritems():
totalpop += stats['pop']
totalvotes += stats['votes']
num_per = totalpop/float(totalvotes)
print "total", totalpop, "votes", totalvotes, num_per
closest = 0.0
for state,stats in data.iteritems():
state_per = stats['pop']/float(stats['votes'])
worth = num_per/state_per
dist = abs(1-worth)
print state, worth, dist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment