diff --git a/census_apportionment_tables/1990_apportionment_cleaned.tsv b/census_apportionment_tables/1990_apportionment_cleaned.tsv new file mode 100644 index 0000000..56c9c05 --- /dev/null +++ b/census_apportionment_tables/1990_apportionment_cleaned.tsv @@ -0,0 +1,52 @@ +STATES SIZE OF STATE DELEGATION APPORTIONMENT POPULATION RESIDENT POPULATION UNITED STATES POPULATION ABROAD TOTAL ELECTORAL VOTES NUMBER OF CITIZENS PER ELECTORAL VOTE +ALABAMA 7 4062608 4040587 22021 9 451400 +ALASKA 1 551947 550043 1904 3 183982 +ARIZONA 6 3677985 3665228 12757 8 459748 +ARKANSAS 4 2362239 2350725 11514 6 393706 +CALIFORNIA 52 29839250 29760021 79229 54 552578 +COLORADO 6 3307912 3294394 13518 8 413489 +CONNECTICUT 6 3295669 3287116 8553 8 411958 +DELAWARE 1 668696 666168 2528 3 222898 +DISTRICT OF COLUMBIA 0 0 606900 3009 3 203303 +FLORIDA 23 13003362 12937926 65436 25 520134 +GEORGIA 11 6508419 6478216 30203 13 500647 +HAWAII 2 1115274 1108229 7045 4 278818 +IDAHO 2 1011986 1006749 5237 4 252996 +ILLINOIS 20 11466682 11430602 36080 22 521212 +INDIANA 10 5564228 5544159 20069 12 463685 +IOWA 5 2787424 2776755 10669 7 398203 +KANSAS 4 2485600 2477574 8026 6 414266 +KENTUCKY 6 3698969 3685296 13673 8 462371 +LOUISIANA 7 4238216 4219973 18243 9 470912 +MAINE 2 1233223 1227928 5295 4 308305 +MARYLAND 8 4798622 4781468 17154 10 479862 +MASSACHUSETTS 10 6029051 6016425 12626 12 502420 +MICHIGAN 16 9328784 9295297 33487 18 518265 +MINNESOTA 8 4387029 4375099 11930 10 438702 +MISSISSIPPI 5 2586443 2573216 13227 7 369491 +MISSOURI 9 5137804 5117073 20731 11 467073 +MONTANA 1 803655 799065 4590 3 267885 +NEBRASKA 3 1584617 1578385 6232 5 316923 +NEVADA 2 1206152 1201833 4319 4 301538 +NEW HAMPSHIRE 2 1113915 1109252 4663 4 278478 +NEW JERSEY 13 7748634 7730188 18446 15 516575 +NEW MEXICO 3 1521779 1515069 6710 5 304355 +NEW YORK 31 18044505 17990455 54050 33 546803 +NORTH CAROLINA 12 6657630 6628637 28993 14 475545 +NORTH DAKOTA 1 641364 638800 2564 3 213788 +OHIO 19 10887325 10847115 40210 21 518444 +OKLAHOMA 6 3157604 3145585 12019 8 394700 +OREGON 5 2853733 2842321 11412 7 407676 +PENNSYLVANIA 21 11924710 11881643 43067 23 518465 +RHODE ISLAND 2 1005984 1003464 2520 4 251496 +SOUTH CAROLINA 6 3505707 3486703 19004 8 438213 +SOUTH DAKOTA 1 699999 696004 3995 3 233333 +TENNESSEE 9 4896641 4877185 19456 11 445149 +TEXAS 30 17059805 16986510 73295 32 533118 +UTAH 3 1727784 1722850 4934 5 345556 +VERMONT 1 564964 562758 2206 3 188321 +VIRGINIA 11 6216568 6187358 29210 13 478197 +WASHINGTON 9 4887941 4866692 21249 11 444358 +WEST VIRGINIA 3 1801625 1793477 8148 5 360325 +WISCONSIN 9 4906745 4891769 14976 11 446067 +WYOMING 1 455975 453588 2387 3 151991 diff --git a/census_apportionment_tables/2000_apportionment_cleaned.tsv b/census_apportionment_tables/2000_apportionment_cleaned.tsv new file mode 100644 index 0000000..4ae2f3c --- /dev/null +++ b/census_apportionment_tables/2000_apportionment_cleaned.tsv @@ -0,0 +1,51 @@ +STATE APPORTIONMENT POPULATION NUMBER OF APPORTIONED REPRESENTATIVES BASED ON CENSUS 2000 CHANGE FROM 1990 CENSUS APPORTIONMENT TOTAL ELECTORAL VOTES NUMBER OF CITIZENS PER ELECTORAL VOTE + ALABAMA 4461130 7 0 9 495681 + ALASKA 628933 1 0 3 209644 + ARIZONA 5140683 8 +2 10 514068 + ARKANSAS 2679733 4 0 6 446622 + CALIFORNIA 33930798 53 +1 55 616923 + COLORADO 4311882 7 +1 9 479098 + CONNECTICUT 3409535 5 -1 7 487076 + DELAWARE 785068 1 0 3 261689 + FLORIDA 16028890 25 +2 27 593662 + GEORGIA 8206975 13 +2 15 547131 + HAWAII 1216642 2 0 4 304160 + IDAHO 1297274 2 0 4 324318 + ILLINOIS 12439042 19 -1 21 592335 + INDIANA 6090782 9 -1 11 553707 + IOWA 2931923 5 0 7 418846 + KANSAS 2693824 4 0 6 448970 + KENTUCKY 4049431 6 0 8 506178 + LOUISIANA 4480271 7 0 9 497807 + MAINE 1277731 2 0 4 319432 + MARYLAND 5307886 8 0 10 530788 + MASSACHUSETTS 6355568 10 0 12 529630 + MICHIGAN 9955829 15 -1 17 585637 + MINNESOTA 4925670 8 0 10 492567 + MISSISSIPPI 2852927 4 -1 6 475487 + MISSOURI 5606260 9 0 11 509660 + MONTANA 905316 1 0 3 301772 + NEBRASKA 1715369 3 0 5 343073 + NEVADA 2002032 3 +1 5 400406 + NEW HAMPSHIRE 1238415 2 0 4 309603 + NEW JERSEY 8424354 13 0 15 561623 + NEW MEXICO 1823821 3 0 5 364764 + NEW YORK 19004973 29 -2 31 613063 + NORTH CAROLINA 8067673 13 +1 15 537844 + NORTH DAKOTA 643756 1 0 3 214585 + OHIO 11374540 18 -1 20 568727 + OKLAHOMA 3458819 5 -1 7 494117 + OREGON 3428543 5 0 7 489791 + PENNSYLVANIA 12300670 19 -2 21 585746 + RHODE ISLAND 1049662 2 0 4 262415 + SOUTH CAROLINA 4025061 6 0 8 503132 + SOUTH DAKOTA 756874 1 0 3 252291 + TENNESSEE 5700037 9 0 11 518185 + TEXAS 20903994 32 +2 34 614823 + UTAH 2236714 3 0 5 447342 + VERMONT 609890 1 0 3 203296 + VIRGINIA 7100702 11 0 13 546207 + WASHINGTON 5908684 9 0 11 537153 + WEST VIRGINIA 1813077 3 0 5 362615 + WISCONSIN 5371210 8 -1 10 537121 + WYOMING 495304 1 0 3 165101 diff --git a/census_apportionment_tables/2010_apportionment_cleaned.tsv b/census_apportionment_tables/2010_apportionment_cleaned.tsv new file mode 100644 index 0000000..380be10 --- /dev/null +++ b/census_apportionment_tables/2010_apportionment_cleaned.tsv @@ -0,0 +1,51 @@ +STATE APPORTIONMENT POPULATION (APRIL 1, 2010) NUMBER OF APPORTIONED REPRESENTATIVES BASED ON 2010 CENSUS CHANGE IN SEATS FROM CENSUS 2000 APPORTIONMENT TOTAL ELECTORAL VOTES NUMBER OF CITIZENS PER ELECTORAL VOTE +ALABAMA 4802982 7 0 9 533664 +ALASKA 721523 1 0 3 240507 +ARIZONA 6412700 9 +1 11 582972 +ARKANSAS 2926229 4 0 6 487704 +CALIFORNIA 37341989 53 0 55 678945 +COLORADO 5044930 7 0 9 560547 +CONNECTICUT 3581628 5 0 7 511661 +DELAWARE 900877 1 0 3 300292 +FLORIDA 18900773 27 +2 29 651750 +GEORGIA 9727566 14 +1 16 607972 +HAWAII 1366862 2 0 4 341715 +IDAHO 1573499 2 0 4 393374 +ILLINOIS 12864380 18 -1 20 643219 +INDIANA 6501582 9 0 11 591052 +IOWA 3053787 4 -1 6 508964 +KANSAS 2863813 4 0 6 477302 +KENTUCKY 4350606 6 0 8 543825 +LOUISIANA 4553962 6 -1 8 569245 +MAINE 1333074 2 0 4 333268 +MARYLAND 5789929 8 0 10 578992 +MASSACHUSETTS 6559644 9 -1 11 596331 +MICHIGAN 9911626 14 -1 16 619476 +MINNESOTA 5314879 8 0 10 531487 +MISSISSIPPI 2978240 4 0 6 496373 +MISSOURI 6011478 8 -1 10 601147 +MONTANA 994416 1 0 3 331472 +NEBRASKA 1831825 3 0 5 366365 +NEVADA 2709432 4 +1 6 451572 +NEW HAMPSHIRE 1321445 2 0 4 330361 +NEW JERSEY 8807501 12 -1 14 629107 +NEW MEXICO 2067273 3 0 5 413454 +NEW YORK 19421055 27 -2 29 669691 +NORTH CAROLINA 9565781 13 0 15 637718 +NORTH DAKOTA 675905 1 0 3 225301 +OHIO 11568495 16 -2 18 642694 +OKLAHOMA 3764882 5 0 7 537840 +OREGON 3848606 5 0 7 549800 +PENNSYLVANIA 12734905 18 -1 20 636745 +RHODE ISLAND 1055247 2 0 4 263811 +SOUTH CAROLINA 4645975 7 +1 9 516219 +SOUTH DAKOTA 819761 1 0 3 273253 +TENNESSEE 6375431 9 0 11 579584 +TEXAS 25268418 36 +4 38 664958 +UTAH 2770765 4 +1 6 461794 +VERMONT 630337 1 0 3 210112 +VIRGINIA 8037736 11 0 13 618287 +WASHINGTON 6753369 10 +1 12 562780 +WEST VIRGINIA 1859815 3 0 5 371963 +WISCONSIN 5698230 8 0 10 569823 +WYOMING 568300 1 0 3 189433 diff --git a/census_apportionment_tables/scripts/1990_apportionment_raw.csv b/census_apportionment_tables/scripts/1990_apportionment_raw.csv new file mode 100644 index 0000000..f496f68 --- /dev/null +++ b/census_apportionment_tables/scripts/1990_apportionment_raw.csv @@ -0,0 +1 @@ +Table A. Apportionment and Apportionment Population Based on the 1990 Census,,,,,, ,,,,,, States ,Size of State,Apportionment,,United States,, ,delegation,population,Resident population,population abroad,, ,,,,,, United States ,435,"1 249,022,783","248,709,873","922,819",, ,,,,,, Alabama……………………………………..,7,"4,062,608","4,040,587","22,021",, Alaska……………………………………..,1,"551,947","550,043","1,904",, Arizona……………………………………..,6,"3,677,985","3,665,228","12,757",, Arkansas……………………………………..,4,"2,362,239","2,350,725","11,514",, California……………………………………..,52,"29,839,250","29,760,021","79,229",, Colorado……………………………………..,6,"3,307,912","3,294,394","13,518",, Connecticut……………………………………..,6,"3,295,669","3,287,116","8,553",, Delaware……………………………………..,1,"668,696","666,168","2,528",, District of Columbia……………………………………..,...,…,"606,900","3,009",, Florida……………………………………..,23,"13,003,362","12,937,926","65,436",, Georgia……………………………………..,11,"6,508,419","6,478,216","30,203",, Hawaii……………………………………..,2,"1,115,274","1,108,229","7,045",, Idaho……………………………………..,2,"1,011,986","1,006,749","5,237",, Illinois……………………………………..,20,"11,466,682","11,430,602","36,080",, Indiana……………………………………..,10,"5,564,228","5,544,159","20,069",, Iowa……………………………………..,5,"2,787,424","2,776,755","10,669",, Kansas……………………………………..,4,"2,485,600","2,477,574","8,026",, Kentucky……………………………………..,6,"3,698,969","3,685,296","13,673",, Louisiana……………………………………..,7,"4,238,216","4,219,973","18,243",, Maine……………………………………..,2,"1,233,223","1,227,928","5,295",, Maryland……………………………………..,8,"4,798,622","4,781,468","17,154",, Massachusetts……………………………………..,10,"6,029,051","6,016,425","12,626",, Michigan……………………………………..,16,"9,328,784","9,295,297","33,487",, Minnesota……………………………………..,8,"4,387,029","4,375,099","11,930",, Mississippi……………………………………..,5,"2,586,443","2,573,216","13,227",, Missouri……………………………………..,9,"5,137,804","5,117,073","20,731",, Montana……………………………………..,1,"803,655","799,065","4,590",, Nebraska……………………………………..,3,"1,584,617","1,578,385","6,232",, Nevada……………………………………..,2,"1,206,152","1,201,833","4,319",, New Hampshire……………………………………..,2,"1,113,915","1,109,252","4,663",, New Jersey……………………………………..,13,"7,748,634","7,730,188","18,446",, New Mexico……………………………………..,3,"1,521,779","1,515,069","6,710",, New York……………………………………..,31,"18,044,505","17,990,455","54,050",, North Carolina……………………………………..,12,"6,657,630","6,628,637","28,993",, North Dakota……………………………………..,1,"641,364","638,800","2,564",, Ohio……………………………………..,19,"10,887,325","10,847,115","40,210",, Oklahoma……………………………………..,6,"3,157,604","3,145,585","12,019",, Oregon……………………………………..,5,"2,853,733","2,842,321","11,412",, Pennsylvania……………………………………..,21,"11,924,710","11,881,643","43,067",, Rhode Island……………………………………..,2,"1,005,984","1,003,464","2,520",, South Carolina……………………………………..,6,"3,505,707","3,486,703","19,004",, South Dakota……………………………………..,1,"699,999","696,004","3,995",, Tennessee……………………………………..,9,"4,896,641","4,877,185","19,456",, Texas……………………………………..,30,"17,059,805","16,986,510","73,295",, Utah……………………………………..,3,"1,727,784","1,722,850","4,934",, Vermont……………………………………..,1,"564,964","562,758","2,206",, Virginia……………………………………..,11,"6,216,568","6,187,358","29,210",, Washington……………………………………..,9,"4,887,941","4,866,692","21,249",, West Virginia……………………………………..,3,"1,801,625","1,793,477","8,148",, Wisconsin……………………………………..,9,"4,906,745","4,891,769","14,976",, Wyoming……………………………………..,1,"455,975","453,588","2,387",, ,,,,,, 1 The apportionment population does not include the resident or the overseas population for the District of Columbia,,,,,, \ No newline at end of file diff --git a/census_apportionment_tables/scripts/1990_apportionment_raw.txt b/census_apportionment_tables/scripts/1990_apportionment_raw.txt new file mode 100644 index 0000000..82b135d --- /dev/null +++ b/census_apportionment_tables/scripts/1990_apportionment_raw.txt @@ -0,0 +1 @@ +Table A. Apportionment and Apportionment Population Based on the 1990 Census States Size of State Apportionment United States delegation population Resident population population abroad United States 435 "1 249,022,783" "248,709,873" "922,819" AlabamaÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 7 "4,062,608" "4,040,587" "22,021" AlaskaÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 1 "551,947" "550,043" "1,904" ArizonaÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 6 "3,677,985" "3,665,228" "12,757" ArkansasÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 4 "2,362,239" "2,350,725" "11,514" CaliforniaÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 52 "29,839,250" "29,760,021" "79,229" ColoradoÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 6 "3,307,912" "3,294,394" "13,518" ConnecticutÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 6 "3,295,669" "3,287,116" "8,553" DelawareÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 1 "668,696" "666,168" "2,528" District of ColumbiaÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. ... É "606,900" "3,009" FloridaÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 23 "13,003,362" "12,937,926" "65,436" GeorgiaÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 11 "6,508,419" "6,478,216" "30,203" HawaiiÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 2 "1,115,274" "1,108,229" "7,045" IdahoÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 2 "1,011,986" "1,006,749" "5,237" IllinoisÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 20 "11,466,682" "11,430,602" "36,080" IndianaÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 10 "5,564,228" "5,544,159" "20,069" IowaÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 5 "2,787,424" "2,776,755" "10,669" KansasÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 4 "2,485,600" "2,477,574" "8,026" KentuckyÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 6 "3,698,969" "3,685,296" "13,673" LouisianaÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 7 "4,238,216" "4,219,973" "18,243" MaineÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 2 "1,233,223" "1,227,928" "5,295" MarylandÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 8 "4,798,622" "4,781,468" "17,154" MassachusettsÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 10 "6,029,051" "6,016,425" "12,626" MichiganÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 16 "9,328,784" "9,295,297" "33,487" MinnesotaÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 8 "4,387,029" "4,375,099" "11,930" MississippiÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 5 "2,586,443" "2,573,216" "13,227" MissouriÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 9 "5,137,804" "5,117,073" "20,731" MontanaÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 1 "803,655" "799,065" "4,590" NebraskaÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 3 "1,584,617" "1,578,385" "6,232" NevadaÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 2 "1,206,152" "1,201,833" "4,319" New HampshireÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 2 "1,113,915" "1,109,252" "4,663" New JerseyÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 13 "7,748,634" "7,730,188" "18,446" New MexicoÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 3 "1,521,779" "1,515,069" "6,710" New YorkÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 31 "18,044,505" "17,990,455" "54,050" North CarolinaÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 12 "6,657,630" "6,628,637" "28,993" North DakotaÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 1 "641,364" "638,800" "2,564" OhioÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 19 "10,887,325" "10,847,115" "40,210" OklahomaÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 6 "3,157,604" "3,145,585" "12,019" OregonÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 5 "2,853,733" "2,842,321" "11,412" PennsylvaniaÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 21 "11,924,710" "11,881,643" "43,067" Rhode IslandÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 2 "1,005,984" "1,003,464" "2,520" South CarolinaÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 6 "3,505,707" "3,486,703" "19,004" South DakotaÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 1 "699,999" "696,004" "3,995" TennesseeÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 9 "4,896,641" "4,877,185" "19,456" TexasÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 30 "17,059,805" "16,986,510" "73,295" UtahÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 3 "1,727,784" "1,722,850" "4,934" VermontÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 1 "564,964" "562,758" "2,206" VirginiaÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 11 "6,216,568" "6,187,358" "29,210" WashingtonÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 9 "4,887,941" "4,866,692" "21,249" West VirginiaÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 3 "1,801,625" "1,793,477" "8,148" WisconsinÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 9 "4,906,745" "4,891,769" "14,976" WyomingÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 1 "455,975" "453,588" "2,387" 1 The apportionment population does not include the resident or the overseas population for the District of Columbia \ No newline at end of file diff --git a/census_apportionment_tables/scripts/2000_apportionment_raw.txt b/census_apportionment_tables/scripts/2000_apportionment_raw.txt new file mode 100644 index 0000000..9984a4b --- /dev/null +++ b/census_apportionment_tables/scripts/2000_apportionment_raw.txt @@ -0,0 +1 @@ +"Table 1. Apportionment Population and Number of Representatives, by State: Census 2000" State Apportionment Population Number of Apportioned Representatives Based on Census 2000 Change From 1990 Census Apportionment Alabama "4,461,130" 7 0 Alaska "628,933" 1 0 Arizona "5,140,683" 8 +2 Arkansas "2,679,733" 4 0 California "33,930,798" 53 +1 Colorado "4,311,882" 7 +1 Connecticut "3,409,535" 5 -1 Delaware "785,068" 1 0 Florida "16,028,890" 25 +2 Georgia "8,206,975" 13 +2 Hawaii "1,216,642" 2 0 Idaho "1,297,274" 2 0 Illinois "12,439,042" 19 -1 Indiana "6,090,782" 9 -1 Iowa "2,931,923" 5 0 Kansas "2,693,824" 4 0 Kentucky "4,049,431" 6 0 Louisiana "4,480,271" 7 0 Maine "1,277,731" 2 0 Maryland "5,307,886" 8 0 Massachusetts "6,355,568" 10 0 Michigan "9,955,829" 15 -1 Minnesota "4,925,670" 8 0 Mississippi "2,852,927" 4 -1 Missouri "5,606,260" 9 0 Montana "905,316" 1 0 Nebraska "1,715,369" 3 0 Nevada "2,002,032" 3 +1 New Hampshire "1,238,415" 2 0 New Jersey "8,424,354" 13 0 New Mexico "1,823,821" 3 0 New York "19,004,973" 29 -2 North Carolina "8,067,673" 13 +1 North Dakota "643,756" 1 0 Ohio "11,374,540" 18 -1 Oklahoma "3,458,819" 5 -1 Oregon "3,428,543" 5 0 Pennsylvania "12,300,670" 19 -2 Rhode Island "1,049,662" 2 0 South Carolina "4,025,061" 6 0 South Dakota "756,874" 1 0 Tennessee "5,700,037" 9 0 Texas "20,903,994" 32 +2 Utah "2,236,714" 3 0 Vermont "609,890" 1 0 Virginia "7,100,702" 11 0 Washington "5,908,684" 9 0 West Virginia "1,813,077" 3 0 Wisconsin "5,371,210" 8 -1 Wyoming "495,304" 1 0 Total Apportionment Population1 "281,424,177" 435 "1 Includes the resident population for the 50 states, as ascertained by the Twenty-Second Decennial Census under Title 13," "United States Code, and counts of overseas U.S. military and federal civilian employees (and their dependents living with them) " "allocated to their home state, as reported by the employing federal agencies. The apportionment population excludes the population" of the District of Columbia. "NOTE: As required by the January 1999 U.S. Supreme Court ruling (Department of Commerce v. House of Representatives, " "525 U.S. 316, 119 S. Ct. 765 (1999)), the apportionment population counts do not reflect the use of statistical sampling to correct" for overcounting or undercounting. "Source: U.S. Department of Commerce, U.S. Census Bureau." "Internet Release date: December 28, 2000" \ No newline at end of file diff --git a/census_apportionment_tables/scripts/2000_approtionment_raw.csv b/census_apportionment_tables/scripts/2000_approtionment_raw.csv new file mode 100644 index 0000000..7f34880 --- /dev/null +++ b/census_apportionment_tables/scripts/2000_approtionment_raw.csv @@ -0,0 +1 @@ +"Table 1. Apportionment Population and Number of Representatives, by State: Census 2000",,,,, ,,,,, State,Apportionment Population,Number of Apportioned Representatives Based on Census 2000,Change From 1990 Census Apportionment,, ,,,,, ,,,,, ,,,,, Alabama,"4,461,130",7,0,, Alaska,"628,933",1,0,, Arizona,"5,140,683",8,+2,, Arkansas,"2,679,733",4,0,, California,"33,930,798",53,+1,, Colorado,"4,311,882",7,+1,, Connecticut,"3,409,535",5,-1,, Delaware,"785,068",1,0,, Florida,"16,028,890",25,+2,, Georgia,"8,206,975",13,+2,, Hawaii,"1,216,642",2,0,, Idaho,"1,297,274",2,0,, Illinois,"12,439,042",19,-1,, Indiana,"6,090,782",9,-1,, Iowa,"2,931,923",5,0,, Kansas,"2,693,824",4,0,, Kentucky,"4,049,431",6,0,, Louisiana,"4,480,271",7,0,, Maine,"1,277,731",2,0,, Maryland,"5,307,886",8,0,, Massachusetts,"6,355,568",10,0,, Michigan,"9,955,829",15,-1,, Minnesota,"4,925,670",8,0,, Mississippi,"2,852,927",4,-1,, Missouri,"5,606,260",9,0,, Montana,"905,316",1,0,, Nebraska,"1,715,369",3,0,, Nevada,"2,002,032",3,+1,, New Hampshire,"1,238,415",2,0,, New Jersey,"8,424,354",13,0,, New Mexico,"1,823,821",3,0,, New York,"19,004,973",29,-2,, North Carolina,"8,067,673",13,+1,, North Dakota,"643,756",1,0,, Ohio,"11,374,540",18,-1,, Oklahoma,"3,458,819",5,-1,, Oregon,"3,428,543",5,0,, Pennsylvania,"12,300,670",19,-2,, Rhode Island,"1,049,662",2,0,, South Carolina,"4,025,061",6,0,, South Dakota,"756,874",1,0,, Tennessee,"5,700,037",9,0,, Texas,"20,903,994",32,+2,, Utah,"2,236,714",3,0,, Vermont,"609,890",1,0,, Virginia,"7,100,702",11,0,, Washington,"5,908,684",9,0,, West Virginia,"1,813,077",3,0,, Wisconsin,"5,371,210",8,-1,, Wyoming,"495,304",1,0,, ,,,,, Total Apportionment Population1,"281,424,177",435,,, ,,,,, "1 Includes the resident population for the 50 states, as ascertained by the Twenty-Second Decennial Census under Title 13,",,,,, "United States Code, and counts of overseas U.S. military and federal civilian employees (and their dependents living with them) ",,,,, "allocated to their home state, as reported by the employing federal agencies. The apportionment population excludes the population",,,,, of the District of Columbia.,,,,, "NOTE: As required by the January 1999 U.S. Supreme Court ruling (Department of Commerce v. House of Representatives, ",,,,, "525 U.S. 316, 119 S. Ct. 765 (1999)), the apportionment population counts do not reflect the use of statistical sampling to correct",,,,, for overcounting or undercounting.,,,,, "Source: U.S. Department of Commerce, U.S. Census Bureau.",,,,, "Internet Release date: December 28, 2000",,,,, \ No newline at end of file diff --git a/census_apportionment_tables/scripts/2010_apportionment_raw.csv b/census_apportionment_tables/scripts/2010_apportionment_raw.csv new file mode 100644 index 0000000..589893c --- /dev/null +++ b/census_apportionment_tables/scripts/2010_apportionment_raw.csv @@ -0,0 +1 @@ +U.S. Department of Commerce,,,,,,, U.S. Census Bureau,,,,,,, ,,,,,,, "Table 1. APPORTIONMENT POPULATION AND NUMBER OF REPRESENTATIVES, BY STATE: 2010 CENSUS",,,,,,, ,,,,,,, ,,,NUMBER OF APPORTIONED,,,, ,APPORTIONMENT,,REPRESENTATIVES,,CHANGE IN SEATS,, ,POPULATION,,BASED ON,,FROM CENSUS 2000,, STATE,"(APRIL 1, 2010)",,2010 CENSUS,,APPORTIONMENT,, ,,,,,,, ,,,,,,, Alabama,"4,802,982",,7,,0,, Alaska,"721,523",,1,,0,, Arizona,"6,412,700",,9,,+1,, Arkansas,"2,926,229",,4,,0,, California,"37,341,989",,53,,0,, Colorado,"5,044,930",,7,,0,, Connecticut,"3,581,628",,5,,0,, Delaware,"900,877",,1,,0,, Florida,"18,900,773",,27,,+2,, Georgia,"9,727,566",,14,,+1,, Hawaii,"1,366,862",,2,,0,, Idaho,"1,573,499",,2,,0,, Illinois,"12,864,380",,18,,-1,, Indiana,"6,501,582",,9,,0,, Iowa,"3,053,787",,4,,-1,, Kansas,"2,863,813",,4,,0,, Kentucky,"4,350,606",,6,,0,, Louisiana,"4,553,962",,6,,-1,, Maine,"1,333,074",,2,,0,, Maryland,"5,789,929",,8,,0,, Massachusetts,"6,559,644",,9,,-1,, Michigan,"9,911,626",,14,,-1,, Minnesota,"5,314,879",,8,,0,, Mississippi,"2,978,240",,4,,0,, Missouri,"6,011,478",,8,,-1,, Montana,"994,416",,1,,0,, Nebraska,"1,831,825",,3,,0,, Nevada,"2,709,432",,4,,+1,, New Hampshire,"1,321,445",,2,,0,, New Jersey,"8,807,501",,12,,-1,, New Mexico,"2,067,273",,3,,0,, New York,"19,421,055",,27,,-2,, North Carolina,"9,565,781",,13,,0,, North Dakota,"675,905",,1,,0,, Ohio,"11,568,495",,16,,-2,, Oklahoma,"3,764,882",,5,,0,, Oregon,"3,848,606",,5,,0,, Pennsylvania,"12,734,905",,18,,-1,, Rhode Island,"1,055,247",,2,,0,, South Carolina,"4,645,975",,7,,+1,, South Dakota,"819,761",,1,,0,, Tennessee,"6,375,431",,9,,0,, Texas,"25,268,418",,36,,+4,, Utah,"2,770,765",,4,,+1,, Vermont,"630,337",,1,,0,, Virginia,"8,037,736",,11,,0,, Washington,"6,753,369",,10,,+1,, West Virginia,"1,859,815",,3,,0,, Wisconsin,"5,698,230",,8,,0,, Wyoming,"568,300",,1,,0,, TOTAL1,"309,183,463",,435,,,, ,,,,,,, " 1 Apportionment population includes the resident population for the 50 states, as ascertained by the Twenty-Third",,,,,,, "Decennial Census under Title 13, United States Code, and counts of overseas U.S. military and federal ",,,,,,, "civilian employees (and their dependents living with them) allocated to their home state, as reported by",,,,,,, the employing federal agencies. The apportionment population excludes the population of the District of Columbia.,,,,,,, \ No newline at end of file diff --git a/census_apportionment_tables/scripts/2010_apportionment_raw.txt b/census_apportionment_tables/scripts/2010_apportionment_raw.txt new file mode 100644 index 0000000..4e1260b --- /dev/null +++ b/census_apportionment_tables/scripts/2010_apportionment_raw.txt @@ -0,0 +1 @@ +U.S. Department of Commerce U.S. Census Bureau "Table 1. APPORTIONMENT POPULATION AND NUMBER OF REPRESENTATIVES, BY STATE: 2010 CENSUS" NUMBER OF APPORTIONED APPORTIONMENT REPRESENTATIVES CHANGE IN SEATS POPULATION BASED ON FROM CENSUS 2000 STATE "(APRIL 1, 2010)" 2010 CENSUS APPORTIONMENT Alabama "4,802,982" 7 0 Alaska "721,523" 1 0 Arizona "6,412,700" 9 +1 Arkansas "2,926,229" 4 0 California "37,341,989" 53 0 Colorado "5,044,930" 7 0 Connecticut "3,581,628" 5 0 Delaware "900,877" 1 0 Florida "18,900,773" 27 +2 Georgia "9,727,566" 14 +1 Hawaii "1,366,862" 2 0 Idaho "1,573,499" 2 0 Illinois "12,864,380" 18 -1 Indiana "6,501,582" 9 0 Iowa "3,053,787" 4 -1 Kansas "2,863,813" 4 0 Kentucky "4,350,606" 6 0 Louisiana "4,553,962" 6 -1 Maine "1,333,074" 2 0 Maryland "5,789,929" 8 0 Massachusetts "6,559,644" 9 -1 Michigan "9,911,626" 14 -1 Minnesota "5,314,879" 8 0 Mississippi "2,978,240" 4 0 Missouri "6,011,478" 8 -1 Montana "994,416" 1 0 Nebraska "1,831,825" 3 0 Nevada "2,709,432" 4 +1 New Hampshire "1,321,445" 2 0 New Jersey "8,807,501" 12 -1 New Mexico "2,067,273" 3 0 New York "19,421,055" 27 -2 North Carolina "9,565,781" 13 0 North Dakota "675,905" 1 0 Ohio "11,568,495" 16 -2 Oklahoma "3,764,882" 5 0 Oregon "3,848,606" 5 0 Pennsylvania "12,734,905" 18 -1 Rhode Island "1,055,247" 2 0 South Carolina "4,645,975" 7 +1 South Dakota "819,761" 1 0 Tennessee "6,375,431" 9 0 Texas "25,268,418" 36 +4 Utah "2,770,765" 4 +1 Vermont "630,337" 1 0 Virginia "8,037,736" 11 0 Washington "6,753,369" 10 +1 West Virginia "1,859,815" 3 0 Wisconsin "5,698,230" 8 0 Wyoming "568,300" 1 0 TOTAL1 "309,183,463" 435 " 1 Apportionment population includes the resident population for the 50 states, as ascertained by the Twenty-Third" "Decennial Census under Title 13, United States Code, and counts of overseas U.S. military and federal " "civilian employees (and their dependents living with them) allocated to their home state, as reported by" the employing federal agencies. The apportionment population excludes the population of the District of Columbia. \ No newline at end of file diff --git a/census_apportionment_tables/scripts/appropriation_cleanup.ipynb b/census_apportionment_tables/scripts/appropriation_cleanup.ipynb new file mode 100644 index 0000000..b303959 --- /dev/null +++ b/census_apportionment_tables/scripts/appropriation_cleanup.ipynb @@ -0,0 +1,4701 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "'3.5.2 |Anaconda 4.1.1 (x86_64)| (default, Jul 2 2016, 17:52:12) \\n[GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)]'" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import numpy as np\n", + "import pandas as pd\n", + "import sys\n", + "sys.version" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0 Table A. Apportionment and Apportionment Population Based on the 1990 Census,,,,,,\n", + "\n", + "1 ,,,,,,\n", + "\n", + "2 States ,Size of State,Apportionment,,United States,,\n", + "\n", + "3 ,delegation,population,Resident population,population abroad,,\n", + "\n", + "4 ,,,,,,\n", + "\n", + "5 United States ,435,\"1 249,022,783\",\"248,709,873\",\"922,819\",,\n", + "\n", + "6 ,,,,,,\n", + "\n", + "7 Alabama……………………………………..,7,\"4,062,608\",\"4,040,587\",\"22,021\",,\n", + "\n", + "8 Alaska……………………………………..,1,\"551,947\",\"550,043\",\"1,904\",,\n", + "\n", + "9 Arizona……………………………………..,6,\"3,677,985\",\"3,665,228\",\"12,757\",,\n", + "\n", + "10 Arkansas……………………………………..,4,\"2,362,239\",\"2,350,725\",\"11,514\",,\n", + "\n", + "11 California……………………………………..,52,\"29,839,250\",\"29,760,021\",\"79,229\",,\n", + "\n", + "12 Colorado……………………………………..,6,\"3,307,912\",\"3,294,394\",\"13,518\",,\n", + "\n", + "13 Connecticut……………………………………..,6,\"3,295,669\",\"3,287,116\",\"8,553\",,\n", + "\n", + "14 Delaware……………………………………..,1,\"668,696\",\"666,168\",\"2,528\",,\n", + "\n", + "15 District of Columbia……………………………………..,...,…,\"606,900\",\"3,009\",,\n", + "\n", + "16 Florida……………………………………..,23,\"13,003,362\",\"12,937,926\",\"65,436\",,\n", + "\n", + "17 Georgia……………………………………..,11,\"6,508,419\",\"6,478,216\",\"30,203\",,\n", + "\n", + "18 Hawaii……………………………………..,2,\"1,115,274\",\"1,108,229\",\"7,045\",,\n", + "\n", + "19 Idaho……………………………………..,2,\"1,011,986\",\"1,006,749\",\"5,237\",,\n", + "\n", + "20 Illinois……………………………………..,20,\"11,466,682\",\"11,430,602\",\"36,080\",,\n", + "\n", + "21 Indiana……………………………………..,10,\"5,564,228\",\"5,544,159\",\"20,069\",,\n", + "\n", + "22 Iowa……………………………………..,5,\"2,787,424\",\"2,776,755\",\"10,669\",,\n", + "\n", + "23 Kansas……………………………………..,4,\"2,485,600\",\"2,477,574\",\"8,026\",,\n", + "\n", + "24 Kentucky……………………………………..,6,\"3,698,969\",\"3,685,296\",\"13,673\",,\n", + "\n", + "25 Louisiana……………………………………..,7,\"4,238,216\",\"4,219,973\",\"18,243\",,\n", + "\n", + "26 Maine……………………………………..,2,\"1,233,223\",\"1,227,928\",\"5,295\",,\n", + "\n", + "27 Maryland……………………………………..,8,\"4,798,622\",\"4,781,468\",\"17,154\",,\n", + "\n", + "28 Massachusetts……………………………………..,10,\"6,029,051\",\"6,016,425\",\"12,626\",,\n", + "\n", + "29 Michigan……………………………………..,16,\"9,328,784\",\"9,295,297\",\"33,487\",,\n", + "\n", + "30 Minnesota……………………………………..,8,\"4,387,029\",\"4,375,099\",\"11,930\",,\n", + "\n", + "31 Mississippi……………………………………..,5,\"2,586,443\",\"2,573,216\",\"13,227\",,\n", + "\n", + "32 Missouri……………………………………..,9,\"5,137,804\",\"5,117,073\",\"20,731\",,\n", + "\n", + "33 Montana……………………………………..,1,\"803,655\",\"799,065\",\"4,590\",,\n", + "\n", + "34 Nebraska……………………………………..,3,\"1,584,617\",\"1,578,385\",\"6,232\",,\n", + "\n", + "35 Nevada……………………………………..,2,\"1,206,152\",\"1,201,833\",\"4,319\",,\n", + "\n", + "36 New Hampshire……………………………………..,2,\"1,113,915\",\"1,109,252\",\"4,663\",,\n", + "\n", + "37 New Jersey……………………………………..,13,\"7,748,634\",\"7,730,188\",\"18,446\",,\n", + "\n", + "38 New Mexico……………………………………..,3,\"1,521,779\",\"1,515,069\",\"6,710\",,\n", + "\n", + "39 New York……………………………………..,31,\"18,044,505\",\"17,990,455\",\"54,050\",,\n", + "\n", + "40 North Carolina……………………………………..,12,\"6,657,630\",\"6,628,637\",\"28,993\",,\n", + "\n", + "41 North Dakota……………………………………..,1,\"641,364\",\"638,800\",\"2,564\",,\n", + "\n", + "42 Ohio……………………………………..,19,\"10,887,325\",\"10,847,115\",\"40,210\",,\n", + "\n", + "43 Oklahoma……………………………………..,6,\"3,157,604\",\"3,145,585\",\"12,019\",,\n", + "\n", + "44 Oregon……………………………………..,5,\"2,853,733\",\"2,842,321\",\"11,412\",,\n", + "\n", + "45 Pennsylvania……………………………………..,21,\"11,924,710\",\"11,881,643\",\"43,067\",,\n", + "\n", + "46 Rhode Island……………………………………..,2,\"1,005,984\",\"1,003,464\",\"2,520\",,\n", + "\n", + "47 South Carolina……………………………………..,6,\"3,505,707\",\"3,486,703\",\"19,004\",,\n", + "\n", + "48 South Dakota……………………………………..,1,\"699,999\",\"696,004\",\"3,995\",,\n", + "\n", + "49 Tennessee……………………………………..,9,\"4,896,641\",\"4,877,185\",\"19,456\",,\n", + "\n", + "50 Texas……………………………………..,30,\"17,059,805\",\"16,986,510\",\"73,295\",,\n", + "\n", + "51 Utah……………………………………..,3,\"1,727,784\",\"1,722,850\",\"4,934\",,\n", + "\n", + "52 Vermont……………………………………..,1,\"564,964\",\"562,758\",\"2,206\",,\n", + "\n", + "53 Virginia……………………………………..,11,\"6,216,568\",\"6,187,358\",\"29,210\",,\n", + "\n", + "54 Washington……………………………………..,9,\"4,887,941\",\"4,866,692\",\"21,249\",,\n", + "\n", + "55 West Virginia……………………………………..,3,\"1,801,625\",\"1,793,477\",\"8,148\",,\n", + "\n", + "56 Wisconsin……………………………………..,9,\"4,906,745\",\"4,891,769\",\"14,976\",,\n", + "\n", + "57 Wyoming……………………………………..,1,\"455,975\",\"453,588\",\"2,387\",,\n", + "\n", + "58 ,,,,,,\n", + "\n", + "59 1 The apportionment population does not include the resident or the overseas population for the District of Columbia,,,,,,\n" + ] + } + ], + "source": [ + "### review the 1990 file\n", + "\n", + "with open('1990_apportionment_raw.csv', 'r') as f:\n", + " w = 0\n", + " for line in f.readlines():\n", + " print(w, line)\n", + " w +=1" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "### lordy, that is horrid. Try with csv reader\n", + "import csv" + ] + }, + { + "cell_type": "code", + "execution_count": 37, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "60" + ] + }, + "execution_count": 37, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "with open('1990_apportionment_raw.txt', newline='') as csvfile:\n", + " reader = csv.reader(csvfile, delimiter='\\t', quotechar='|')\n", + " #for row in reader:\n", + " # print(row)\n", + " f = [x for x in reader]\n", + " \n", + "len(f) " + ] + }, + { + "cell_type": "code", + "execution_count": 40, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "[['States ', 'Size of State', 'Apportionment', '', 'United States', '', ''],\n", + " ['',\n", + " 'delegation',\n", + " 'population',\n", + " 'Resident population',\n", + " 'population abroad',\n", + " '',\n", + " '']]" + ] + }, + "execution_count": 40, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "f[2:4]" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "'State'" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "(f[2][0].strip() + ' '+ f[3][0].strip()).strip()" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "'delegation'" + ] + }, + "execution_count": 31, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "f[3][1]" + ] + }, + { + "cell_type": "code", + "execution_count": 41, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "['States',\n", + " 'Size of State delegation',\n", + " 'Apportionment population',\n", + " 'Resident population',\n", + " 'United States population abroad',\n", + " '',\n", + " '']" + ] + }, + "execution_count": 41, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "header_names = [(f[2][x].strip() + ' '+ f[3][x].strip()).strip() for x in range(len(f[2]))]\n", + "header_names" + ] + }, + { + "cell_type": "code", + "execution_count": 47, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " at 0x114150ae8> some\u0000string. with\u0015 funny characters\n" + ] + } + ], + "source": [ + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 56, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "import re\n", + "fxn = lambda x: re.sub(r'[^\\x00-\\x7f]',r'',x).strip('.')" + ] + }, + { + "cell_type": "code", + "execution_count": 58, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "'Alabama'" + ] + }, + "execution_count": 58, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "fxn(f[7][0])" + ] + }, + { + "cell_type": "code", + "execution_count": 111, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "60" + ] + }, + "execution_count": 111, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import re\n", + "fxn = lambda x: re.sub(r'[^\\x00-\\x7f]',r'',x).strip('.').strip('\"').upper()\n", + "g = []\n", + "with open('1990_apportionment_raw.txt', newline='') as csvfile:\n", + " reader = csv.reader(csvfile, delimiter='\\t', quotechar='|')\n", + " for row in reader:\n", + " g.append([fxn(x) for x in row[:5]])\n", + " \n", + " \n", + "len(g) " + ] + }, + { + "cell_type": "code", + "execution_count": 109, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "'ALASKA'" + ] + }, + "execution_count": 109, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "fxn(f[8][0])" + ] + }, + { + "cell_type": "code", + "execution_count": 110, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "['ALASKA', '1', '551,947', '550,043', '1,904', '']" + ] + }, + "execution_count": 110, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "g[8]" + ] + }, + { + "cell_type": "code", + "execution_count": 112, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "header_names = [(g[2][x].strip() + ' '+ g[3][x].strip()).strip() for x in range(len(g[2]))]" + ] + }, + { + "cell_type": "code", + "execution_count": 113, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "['STATES',\n", + " 'SIZE OF STATE DELEGATION',\n", + " 'APPORTIONMENT POPULATION',\n", + " 'RESIDENT POPULATION',\n", + " 'UNITED STATES POPULATION ABROAD']" + ] + }, + "execution_count": 113, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "header_names" + ] + }, + { + "cell_type": "code", + "execution_count": 114, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "['ALABAMA', '7', '4,062,608', '4,040,587', '22,021']" + ] + }, + "execution_count": 114, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "g[7]" + ] + }, + { + "cell_type": "code", + "execution_count": 115, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "['WYOMING', '1', '455,975', '453,588', '2,387']" + ] + }, + "execution_count": 115, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "g[57]" + ] + }, + { + "cell_type": "code", + "execution_count": 242, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "g1 = g[7:58]" + ] + }, + { + "cell_type": "code", + "execution_count": 243, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "['WYOMING', '1', '455,975', '453,588', '2,387']" + ] + }, + "execution_count": 243, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "g1[-1]" + ] + }, + { + "cell_type": "code", + "execution_count": 244, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "ca1990 = pd.DataFrame(g1, columns=header_names) " + ] + }, + { + "cell_type": "code", + "execution_count": 245, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
STATESSIZE OF STATE DELEGATIONAPPORTIONMENT POPULATIONRESIDENT POPULATIONUNITED STATES POPULATION ABROAD
0ALABAMA74,062,6084,040,58722,021
1ALASKA1551,947550,0431,904
2ARIZONA63,677,9853,665,22812,757
3ARKANSAS42,362,2392,350,72511,514
4CALIFORNIA5229,839,25029,760,02179,229
\n", + "
" + ], + "text/plain": [ + " STATES SIZE OF STATE DELEGATION APPORTIONMENT POPULATION \\\n", + "0 ALABAMA 7 4,062,608 \n", + "1 ALASKA 1 551,947 \n", + "2 ARIZONA 6 3,677,985 \n", + "3 ARKANSAS 4 2,362,239 \n", + "4 CALIFORNIA 52 29,839,250 \n", + "\n", + " RESIDENT POPULATION UNITED STATES POPULATION ABROAD \n", + "0 4,040,587 22,021 \n", + "1 550,043 1,904 \n", + "2 3,665,228 12,757 \n", + "3 2,350,725 11,514 \n", + "4 29,760,021 79,229 " + ] + }, + "execution_count": 245, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "ca1990.head()" + ] + }, + { + "cell_type": "code", + "execution_count": 246, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "str" + ] + }, + "execution_count": 246, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "type(ca1990['SIZE OF STATE DELEGATION'][0])" + ] + }, + { + "cell_type": "code", + "execution_count": 129, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 247, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "for y in ca1990.columns[1:]:\n", + " ca1990[y] = ca1990[y].map(\n", + " lambda x: int(x.replace(',','')) if x != '' else 0)" + ] + }, + { + "cell_type": "code", + "execution_count": 248, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
STATESSIZE OF STATE DELEGATIONAPPORTIONMENT POPULATIONRESIDENT POPULATIONUNITED STATES POPULATION ABROAD
0ALABAMA74062608404058722021
1ALASKA15519475500431904
2ARIZONA63677985366522812757
3ARKANSAS42362239235072511514
4CALIFORNIA52298392502976002179229
5COLORADO63307912329439413518
6CONNECTICUT6329566932871168553
7DELAWARE16686966661682528
8DISTRICT OF COLUMBIA006069003009
9FLORIDA23130033621293792665436
10GEORGIA116508419647821630203
11HAWAII2111527411082297045
12IDAHO2101198610067495237
13ILLINOIS20114666821143060236080
14INDIANA105564228554415920069
\n", + "
" + ], + "text/plain": [ + " STATES SIZE OF STATE DELEGATION APPORTIONMENT POPULATION \\\n", + "0 ALABAMA 7 4062608 \n", + "1 ALASKA 1 551947 \n", + "2 ARIZONA 6 3677985 \n", + "3 ARKANSAS 4 2362239 \n", + "4 CALIFORNIA 52 29839250 \n", + "5 COLORADO 6 3307912 \n", + "6 CONNECTICUT 6 3295669 \n", + "7 DELAWARE 1 668696 \n", + "8 DISTRICT OF COLUMBIA 0 0 \n", + "9 FLORIDA 23 13003362 \n", + "10 GEORGIA 11 6508419 \n", + "11 HAWAII 2 1115274 \n", + "12 IDAHO 2 1011986 \n", + "13 ILLINOIS 20 11466682 \n", + "14 INDIANA 10 5564228 \n", + "\n", + " RESIDENT POPULATION UNITED STATES POPULATION ABROAD \n", + "0 4040587 22021 \n", + "1 550043 1904 \n", + "2 3665228 12757 \n", + "3 2350725 11514 \n", + "4 29760021 79229 \n", + "5 3294394 13518 \n", + "6 3287116 8553 \n", + "7 666168 2528 \n", + "8 606900 3009 \n", + "9 12937926 65436 \n", + "10 6478216 30203 \n", + "11 1108229 7045 \n", + "12 1006749 5237 \n", + "13 11430602 36080 \n", + "14 5544159 20069 " + ] + }, + "execution_count": 248, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "ca1990.head(15)" + ] + }, + { + "cell_type": "code", + "execution_count": 249, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "### Twenty-third Amendment gives DC 3 electoral votes \n", + "ca1990['TOTAL ELECTORAL VOTES'] = ca1990['SIZE OF STATE DELEGATION'].map(\n", + " lambda x: int(x)+2 if x != 0 else 3)" + ] + }, + { + "cell_type": "code", + "execution_count": 250, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
STATESSIZE OF STATE DELEGATIONAPPORTIONMENT POPULATIONRESIDENT POPULATIONUNITED STATES POPULATION ABROADTOTAL ELECTORAL VOTES
0ALABAMA740626084040587220219
1ALASKA155194755004319043
2ARIZONA636779853665228127578
3ARKANSAS423622392350725115146
4CALIFORNIA5229839250297600217922954
5COLORADO633079123294394135188
6CONNECTICUT63295669328711685538
7DELAWARE166869666616825283
8DISTRICT OF COLUMBIA0060690030093
9FLORIDA2313003362129379266543625
\n", + "
" + ], + "text/plain": [ + " STATES SIZE OF STATE DELEGATION APPORTIONMENT POPULATION \\\n", + "0 ALABAMA 7 4062608 \n", + "1 ALASKA 1 551947 \n", + "2 ARIZONA 6 3677985 \n", + "3 ARKANSAS 4 2362239 \n", + "4 CALIFORNIA 52 29839250 \n", + "5 COLORADO 6 3307912 \n", + "6 CONNECTICUT 6 3295669 \n", + "7 DELAWARE 1 668696 \n", + "8 DISTRICT OF COLUMBIA 0 0 \n", + "9 FLORIDA 23 13003362 \n", + "\n", + " RESIDENT POPULATION UNITED STATES POPULATION ABROAD TOTAL ELECTORAL VOTES \n", + "0 4040587 22021 9 \n", + "1 550043 1904 3 \n", + "2 3665228 12757 8 \n", + "3 2350725 11514 6 \n", + "4 29760021 79229 54 \n", + "5 3294394 13518 8 \n", + "6 3287116 8553 8 \n", + "7 666168 2528 3 \n", + "8 606900 3009 3 \n", + "9 12937926 65436 25 " + ] + }, + "execution_count": 250, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "ca1990.head(10)" + ] + }, + { + "cell_type": "code", + "execution_count": 251, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "ca1990['NUMBER OF CITIZENS PER ELECTORAL VOTE'] = ca1990['APPORTIONMENT POPULATION']/ca1990['TOTAL ELECTORAL VOTES']" + ] + }, + { + "cell_type": "code", + "execution_count": 252, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "ca1990['NUMBER OF CITIZENS PER ELECTORAL VOTE'] = ca1990['NUMBER OF CITIZENS PER ELECTORAL VOTE'].map(lambda x: int(x))" + ] + }, + { + "cell_type": "code", + "execution_count": 193, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 253, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
STATESSIZE OF STATE DELEGATIONAPPORTIONMENT POPULATIONRESIDENT POPULATIONUNITED STATES POPULATION ABROADTOTAL ELECTORAL VOTESNUMBER OF CITIZENS PER ELECTORAL VOTE
0ALABAMA740626084040587220219451400
1ALASKA155194755004319043183982
2ARIZONA636779853665228127578459748
3ARKANSAS423622392350725115146393706
4CALIFORNIA5229839250297600217922954552578
5COLORADO633079123294394135188413489
6CONNECTICUT63295669328711685538411958
7DELAWARE166869666616825283222898
8DISTRICT OF COLUMBIA00606900300930
9FLORIDA2313003362129379266543625520134
\n", + "
" + ], + "text/plain": [ + " STATES SIZE OF STATE DELEGATION APPORTIONMENT POPULATION \\\n", + "0 ALABAMA 7 4062608 \n", + "1 ALASKA 1 551947 \n", + "2 ARIZONA 6 3677985 \n", + "3 ARKANSAS 4 2362239 \n", + "4 CALIFORNIA 52 29839250 \n", + "5 COLORADO 6 3307912 \n", + "6 CONNECTICUT 6 3295669 \n", + "7 DELAWARE 1 668696 \n", + "8 DISTRICT OF COLUMBIA 0 0 \n", + "9 FLORIDA 23 13003362 \n", + "\n", + " RESIDENT POPULATION UNITED STATES POPULATION ABROAD \\\n", + "0 4040587 22021 \n", + "1 550043 1904 \n", + "2 3665228 12757 \n", + "3 2350725 11514 \n", + "4 29760021 79229 \n", + "5 3294394 13518 \n", + "6 3287116 8553 \n", + "7 666168 2528 \n", + "8 606900 3009 \n", + "9 12937926 65436 \n", + "\n", + " TOTAL ELECTORAL VOTES NUMBER OF CITIZENS PER ELECTORAL VOTE \n", + "0 9 451400 \n", + "1 3 183982 \n", + "2 8 459748 \n", + "3 6 393706 \n", + "4 54 552578 \n", + "5 8 413489 \n", + "6 8 411958 \n", + "7 3 222898 \n", + "8 3 0 \n", + "9 25 520134 " + ] + }, + "execution_count": 253, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "ca1990.head(10)" + ] + }, + { + "cell_type": "code", + "execution_count": 254, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/nicholeh/anaconda/lib/python3.5/site-packages/pandas/core/indexing.py:141: SettingWithCopyWarning: \n", + "A value is trying to be set on a copy of a slice from a DataFrame\n", + "\n", + "See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy\n", + " self._setitem_with_indexer(indexer, value)\n" + ] + } + ], + "source": [ + "### fix DC \n", + "dc_res = ca1990['RESIDENT POPULATION'].ix[8] + ca1990['UNITED STATES POPULATION ABROAD'].ix[8]\n", + "ca1990['NUMBER OF CITIZENS PER ELECTORAL VOTE'].ix[8] = int(dc_res/ca1990['TOTAL ELECTORAL VOTES'].ix[8])" + ] + }, + { + "cell_type": "code", + "execution_count": 255, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
STATESSIZE OF STATE DELEGATIONAPPORTIONMENT POPULATIONRESIDENT POPULATIONUNITED STATES POPULATION ABROADTOTAL ELECTORAL VOTESNUMBER OF CITIZENS PER ELECTORAL VOTE
0ALABAMA740626084040587220219451400
1ALASKA155194755004319043183982
2ARIZONA636779853665228127578459748
3ARKANSAS423622392350725115146393706
4CALIFORNIA5229839250297600217922954552578
5COLORADO633079123294394135188413489
6CONNECTICUT63295669328711685538411958
7DELAWARE166869666616825283222898
8DISTRICT OF COLUMBIA0060690030093203303
9FLORIDA2313003362129379266543625520134
\n", + "
" + ], + "text/plain": [ + " STATES SIZE OF STATE DELEGATION APPORTIONMENT POPULATION \\\n", + "0 ALABAMA 7 4062608 \n", + "1 ALASKA 1 551947 \n", + "2 ARIZONA 6 3677985 \n", + "3 ARKANSAS 4 2362239 \n", + "4 CALIFORNIA 52 29839250 \n", + "5 COLORADO 6 3307912 \n", + "6 CONNECTICUT 6 3295669 \n", + "7 DELAWARE 1 668696 \n", + "8 DISTRICT OF COLUMBIA 0 0 \n", + "9 FLORIDA 23 13003362 \n", + "\n", + " RESIDENT POPULATION UNITED STATES POPULATION ABROAD \\\n", + "0 4040587 22021 \n", + "1 550043 1904 \n", + "2 3665228 12757 \n", + "3 2350725 11514 \n", + "4 29760021 79229 \n", + "5 3294394 13518 \n", + "6 3287116 8553 \n", + "7 666168 2528 \n", + "8 606900 3009 \n", + "9 12937926 65436 \n", + "\n", + " TOTAL ELECTORAL VOTES NUMBER OF CITIZENS PER ELECTORAL VOTE \n", + "0 9 451400 \n", + "1 3 183982 \n", + "2 8 459748 \n", + "3 6 393706 \n", + "4 54 552578 \n", + "5 8 413489 \n", + "6 8 411958 \n", + "7 3 222898 \n", + "8 3 203303 \n", + "9 25 520134 " + ] + }, + "execution_count": 255, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "ca1990.head(10)" + ] + }, + { + "cell_type": "code", + "execution_count": 256, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "total_res = dc[3] + dc[4]" + ] + }, + { + "cell_type": "code", + "execution_count": 257, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "0" + ] + }, + "execution_count": 257, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "dc[2]" + ] + }, + { + "cell_type": "code", + "execution_count": 258, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "ca1990.to_csv('1990_apportionment_cleaned.tsv', sep = '\\t', index=False)" + ] + }, + { + "cell_type": "code", + "execution_count": 241, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 241, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "# 2000 data\n", + "import csv\n", + "with open('2000_apportionment_raw.txt', newline='') as csvfile:\n", + " reader = csv.reader(csvfile, delimiter='\\t', quotechar='|')\n", + " #for row in reader:\n", + " # print(row)\n", + " f = [x for x in reader]" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "[['\"Table 1. Apportionment Population and Number of Representatives, by State: Census 2000\"',\n", + " '',\n", + " '',\n", + " '',\n", + " '',\n", + " ''],\n", + " [' ', '', '', '', '', ''],\n", + " [' State',\n", + " 'Apportionment Population',\n", + " 'Number of Apportioned Representatives Based on Census 2000',\n", + " 'Change From 1990 Census Apportionment',\n", + " '',\n", + " ''],\n", + " ['', '', '', '', '', ''],\n", + " ['', '', '', '', '', '']]" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "f[:5]" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "[' Alabama', '\"4,461,130\"', '7', '0', '', '']" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "f[6]" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "['State',\n", + " 'Apportionment Population',\n", + " 'Number of Apportioned Representatives Based on Census 2000',\n", + " 'Change From 1990 Census Apportionment',\n", + " '',\n", + " '']" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "header_names = [(f[2][x].strip() + ' '+ f[3][x].strip()).strip() for x in range(len(f[2]))]\n", + "header_names" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "68" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import re\n", + "fxn = lambda x: re.sub(r'[^\\x00-\\x7f]',r'',x).strip('.').strip('\"').upper()\n", + "g = []\n", + "with open('2000_apportionment_raw.txt', newline='') as csvfile:\n", + " reader = csv.reader(csvfile, delimiter='\\t', quotechar='|')\n", + " for row in reader:\n", + " g.append([fxn(x) for x in row[:4]])\n", + " \n", + " \n", + "len(g)" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "[['TABLE 1. APPORTIONMENT POPULATION AND NUMBER OF REPRESENTATIVES, BY STATE: CENSUS 2000',\n", + " '',\n", + " '',\n", + " ''],\n", + " [' ', '', '', ''],\n", + " [' STATE',\n", + " 'APPORTIONMENT POPULATION',\n", + " 'NUMBER OF APPORTIONED REPRESENTATIVES BASED ON CENSUS 2000',\n", + " 'CHANGE FROM 1990 CENSUS APPORTIONMENT'],\n", + " ['', '', '', ''],\n", + " ['', '', '', ''],\n", + " ['', '', '', ''],\n", + " [' ALABAMA', '4,461,130', '7', '0'],\n", + " [' ALASKA', '628,933', '1', '0'],\n", + " [' ARIZONA', '5,140,683', '8', '+2'],\n", + " [' ARKANSAS', '2,679,733', '4', '0']]" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "g[:10\n", + "]" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "header_names = [(g[2][x].strip() + ' '+ g[3][x].strip()).strip() for x in range(len(g[2]))]" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "['STATE',\n", + " 'APPORTIONMENT POPULATION',\n", + " 'NUMBER OF APPORTIONED REPRESENTATIVES BASED ON CENSUS 2000',\n", + " 'CHANGE FROM 1990 CENSUS APPORTIONMENT']" + ] + }, + "execution_count": 16, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "header_names" + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "ca2000 = pd.DataFrame(g[6:56], columns=header_names) " + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
STATEAPPORTIONMENT POPULATIONNUMBER OF APPORTIONED REPRESENTATIVES BASED ON CENSUS 2000CHANGE FROM 1990 CENSUS APPORTIONMENT
45VIRGINIA7,100,702110
46WASHINGTON5,908,68490
47WEST VIRGINIA1,813,07730
48WISCONSIN5,371,2108-1
49WYOMING495,30410
\n", + "
" + ], + "text/plain": [ + " STATE APPORTIONMENT POPULATION \\\n", + "45 VIRGINIA 7,100,702 \n", + "46 WASHINGTON 5,908,684 \n", + "47 WEST VIRGINIA 1,813,077 \n", + "48 WISCONSIN 5,371,210 \n", + "49 WYOMING 495,304 \n", + "\n", + " NUMBER OF APPORTIONED REPRESENTATIVES BASED ON CENSUS 2000 \\\n", + "45 11 \n", + "46 9 \n", + "47 3 \n", + "48 8 \n", + "49 1 \n", + "\n", + " CHANGE FROM 1990 CENSUS APPORTIONMENT \n", + "45 0 \n", + "46 0 \n", + "47 0 \n", + "48 -1 \n", + "49 0 " + ] + }, + "execution_count": 27, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "ca2000.tail()" + ] + }, + { + "cell_type": "code", + "execution_count": 28, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
STATEAPPORTIONMENT POPULATIONNUMBER OF APPORTIONED REPRESENTATIVES BASED ON CENSUS 2000CHANGE FROM 1990 CENSUS APPORTIONMENT
0ALABAMA4,461,13070
1ALASKA628,93310
2ARIZONA5,140,6838+2
3ARKANSAS2,679,73340
4CALIFORNIA33,930,79853+1
5COLORADO4,311,8827+1
6CONNECTICUT3,409,5355-1
7DELAWARE785,06810
8FLORIDA16,028,89025+2
9GEORGIA8,206,97513+2
\n", + "
" + ], + "text/plain": [ + " STATE APPORTIONMENT POPULATION \\\n", + "0 ALABAMA 4,461,130 \n", + "1 ALASKA 628,933 \n", + "2 ARIZONA 5,140,683 \n", + "3 ARKANSAS 2,679,733 \n", + "4 CALIFORNIA 33,930,798 \n", + "5 COLORADO 4,311,882 \n", + "6 CONNECTICUT 3,409,535 \n", + "7 DELAWARE 785,068 \n", + "8 FLORIDA 16,028,890 \n", + "9 GEORGIA 8,206,975 \n", + "\n", + " NUMBER OF APPORTIONED REPRESENTATIVES BASED ON CENSUS 2000 \\\n", + "0 7 \n", + "1 1 \n", + "2 8 \n", + "3 4 \n", + "4 53 \n", + "5 7 \n", + "6 5 \n", + "7 1 \n", + "8 25 \n", + "9 13 \n", + "\n", + " CHANGE FROM 1990 CENSUS APPORTIONMENT \n", + "0 0 \n", + "1 0 \n", + "2 +2 \n", + "3 0 \n", + "4 +1 \n", + "5 +1 \n", + "6 -1 \n", + "7 0 \n", + "8 +2 \n", + "9 +2 " + ] + }, + "execution_count": 28, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "ca2000.head(10)" + ] + }, + { + "cell_type": "code", + "execution_count": 29, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "str" + ] + }, + "execution_count": 29, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "type(ca2000['NUMBER OF APPORTIONED REPRESENTATIVES BASED ON CENSUS 2000'][5])" + ] + }, + { + "cell_type": "code", + "execution_count": 30, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "ca2000['NUMBER OF APPORTIONED REPRESENTATIVES BASED ON CENSUS 2000'] = ca2000['NUMBER OF APPORTIONED REPRESENTATIVES BASED ON CENSUS 2000'].map(lambda x: int(x))" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "numpy.int64" + ] + }, + "execution_count": 31, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "type(ca2000['NUMBER OF APPORTIONED REPRESENTATIVES BASED ON CENSUS 2000'][5])" + ] + }, + { + "cell_type": "code", + "execution_count": 32, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
STATEAPPORTIONMENT POPULATIONNUMBER OF APPORTIONED REPRESENTATIVES BASED ON CENSUS 2000CHANGE FROM 1990 CENSUS APPORTIONMENT
0ALABAMA4,461,13070
1ALASKA628,93310
2ARIZONA5,140,6838+2
3ARKANSAS2,679,73340
4CALIFORNIA33,930,79853+1
5COLORADO4,311,8827+1
6CONNECTICUT3,409,5355-1
7DELAWARE785,06810
8FLORIDA16,028,89025+2
9GEORGIA8,206,97513+2
\n", + "
" + ], + "text/plain": [ + " STATE APPORTIONMENT POPULATION \\\n", + "0 ALABAMA 4,461,130 \n", + "1 ALASKA 628,933 \n", + "2 ARIZONA 5,140,683 \n", + "3 ARKANSAS 2,679,733 \n", + "4 CALIFORNIA 33,930,798 \n", + "5 COLORADO 4,311,882 \n", + "6 CONNECTICUT 3,409,535 \n", + "7 DELAWARE 785,068 \n", + "8 FLORIDA 16,028,890 \n", + "9 GEORGIA 8,206,975 \n", + "\n", + " NUMBER OF APPORTIONED REPRESENTATIVES BASED ON CENSUS 2000 \\\n", + "0 7 \n", + "1 1 \n", + "2 8 \n", + "3 4 \n", + "4 53 \n", + "5 7 \n", + "6 5 \n", + "7 1 \n", + "8 25 \n", + "9 13 \n", + "\n", + " CHANGE FROM 1990 CENSUS APPORTIONMENT \n", + "0 0 \n", + "1 0 \n", + "2 +2 \n", + "3 0 \n", + "4 +1 \n", + "5 +1 \n", + "6 -1 \n", + "7 0 \n", + "8 +2 \n", + "9 +2 " + ] + }, + "execution_count": 32, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "ca2000.head(10)" + ] + }, + { + "cell_type": "code", + "execution_count": 33, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "ca2000['APPORTIONMENT POPULATION'] = ca2000['APPORTIONMENT POPULATION'].map(\n", + " lambda x: int(x.replace(',','')) if x != '' else 0)" + ] + }, + { + "cell_type": "code", + "execution_count": 34, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
STATEAPPORTIONMENT POPULATIONNUMBER OF APPORTIONED REPRESENTATIVES BASED ON CENSUS 2000CHANGE FROM 1990 CENSUS APPORTIONMENT
0ALABAMA446113070
1ALASKA62893310
2ARIZONA51406838+2
3ARKANSAS267973340
4CALIFORNIA3393079853+1
5COLORADO43118827+1
6CONNECTICUT34095355-1
7DELAWARE78506810
8FLORIDA1602889025+2
9GEORGIA820697513+2
\n", + "
" + ], + "text/plain": [ + " STATE APPORTIONMENT POPULATION \\\n", + "0 ALABAMA 4461130 \n", + "1 ALASKA 628933 \n", + "2 ARIZONA 5140683 \n", + "3 ARKANSAS 2679733 \n", + "4 CALIFORNIA 33930798 \n", + "5 COLORADO 4311882 \n", + "6 CONNECTICUT 3409535 \n", + "7 DELAWARE 785068 \n", + "8 FLORIDA 16028890 \n", + "9 GEORGIA 8206975 \n", + "\n", + " NUMBER OF APPORTIONED REPRESENTATIVES BASED ON CENSUS 2000 \\\n", + "0 7 \n", + "1 1 \n", + "2 8 \n", + "3 4 \n", + "4 53 \n", + "5 7 \n", + "6 5 \n", + "7 1 \n", + "8 25 \n", + "9 13 \n", + "\n", + " CHANGE FROM 1990 CENSUS APPORTIONMENT \n", + "0 0 \n", + "1 0 \n", + "2 +2 \n", + "3 0 \n", + "4 +1 \n", + "5 +1 \n", + "6 -1 \n", + "7 0 \n", + "8 +2 \n", + "9 +2 " + ] + }, + "execution_count": 34, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "ca2000.head(10)" + ] + }, + { + "cell_type": "code", + "execution_count": 35, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "ca2000['TOTAL ELECTORAL VOTES'] = ca2000['NUMBER OF APPORTIONED REPRESENTATIVES BASED ON CENSUS 2000'] + 2" + ] + }, + { + "cell_type": "code", + "execution_count": 36, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
STATEAPPORTIONMENT POPULATIONNUMBER OF APPORTIONED REPRESENTATIVES BASED ON CENSUS 2000CHANGE FROM 1990 CENSUS APPORTIONMENTTOTAL ELECTORAL VOTES
0ALABAMA4461130709
1ALASKA628933103
2ARIZONA51406838+210
3ARKANSAS2679733406
4CALIFORNIA3393079853+155
5COLORADO43118827+19
6CONNECTICUT34095355-17
7DELAWARE785068103
8FLORIDA1602889025+227
9GEORGIA820697513+215
\n", + "
" + ], + "text/plain": [ + " STATE APPORTIONMENT POPULATION \\\n", + "0 ALABAMA 4461130 \n", + "1 ALASKA 628933 \n", + "2 ARIZONA 5140683 \n", + "3 ARKANSAS 2679733 \n", + "4 CALIFORNIA 33930798 \n", + "5 COLORADO 4311882 \n", + "6 CONNECTICUT 3409535 \n", + "7 DELAWARE 785068 \n", + "8 FLORIDA 16028890 \n", + "9 GEORGIA 8206975 \n", + "\n", + " NUMBER OF APPORTIONED REPRESENTATIVES BASED ON CENSUS 2000 \\\n", + "0 7 \n", + "1 1 \n", + "2 8 \n", + "3 4 \n", + "4 53 \n", + "5 7 \n", + "6 5 \n", + "7 1 \n", + "8 25 \n", + "9 13 \n", + "\n", + " CHANGE FROM 1990 CENSUS APPORTIONMENT TOTAL ELECTORAL VOTES \n", + "0 0 9 \n", + "1 0 3 \n", + "2 +2 10 \n", + "3 0 6 \n", + "4 +1 55 \n", + "5 +1 9 \n", + "6 -1 7 \n", + "7 0 3 \n", + "8 +2 27 \n", + "9 +2 15 " + ] + }, + "execution_count": 36, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "ca2000.head(10)" + ] + }, + { + "cell_type": "code", + "execution_count": 42, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "ca2000['NUMBER OF CITIZENS PER ELECTORAL VOTE'] = ca2000['APPORTIONMENT POPULATION']/ca2000['TOTAL ELECTORAL VOTES']" + ] + }, + { + "cell_type": "code", + "execution_count": 44, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "ca2000['NUMBER OF CITIZENS PER ELECTORAL VOTE'] = ca2000['NUMBER OF CITIZENS PER ELECTORAL VOTE'].map(lambda x: int(x))" + ] + }, + { + "cell_type": "code", + "execution_count": 45, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
STATEAPPORTIONMENT POPULATIONNUMBER OF APPORTIONED REPRESENTATIVES BASED ON CENSUS 2000CHANGE FROM 1990 CENSUS APPORTIONMENTTOTAL ELECTORAL VOTESNUMBER OF CITIZENS PER ELECTORAL VOTE
0ALABAMA4461130709495681
1ALASKA628933103209644
2ARIZONA51406838+210514068
3ARKANSAS2679733406446622
4CALIFORNIA3393079853+155616923
5COLORADO43118827+19479098
6CONNECTICUT34095355-17487076
7DELAWARE785068103261689
8FLORIDA1602889025+227593662
9GEORGIA820697513+215547131
\n", + "
" + ], + "text/plain": [ + " STATE APPORTIONMENT POPULATION \\\n", + "0 ALABAMA 4461130 \n", + "1 ALASKA 628933 \n", + "2 ARIZONA 5140683 \n", + "3 ARKANSAS 2679733 \n", + "4 CALIFORNIA 33930798 \n", + "5 COLORADO 4311882 \n", + "6 CONNECTICUT 3409535 \n", + "7 DELAWARE 785068 \n", + "8 FLORIDA 16028890 \n", + "9 GEORGIA 8206975 \n", + "\n", + " NUMBER OF APPORTIONED REPRESENTATIVES BASED ON CENSUS 2000 \\\n", + "0 7 \n", + "1 1 \n", + "2 8 \n", + "3 4 \n", + "4 53 \n", + "5 7 \n", + "6 5 \n", + "7 1 \n", + "8 25 \n", + "9 13 \n", + "\n", + " CHANGE FROM 1990 CENSUS APPORTIONMENT TOTAL ELECTORAL VOTES \\\n", + "0 0 9 \n", + "1 0 3 \n", + "2 +2 10 \n", + "3 0 6 \n", + "4 +1 55 \n", + "5 +1 9 \n", + "6 -1 7 \n", + "7 0 3 \n", + "8 +2 27 \n", + "9 +2 15 \n", + "\n", + " NUMBER OF CITIZENS PER ELECTORAL VOTE \n", + "0 495681 \n", + "1 209644 \n", + "2 514068 \n", + "3 446622 \n", + "4 616923 \n", + "5 479098 \n", + "6 487076 \n", + "7 261689 \n", + "8 593662 \n", + "9 547131 " + ] + }, + "execution_count": 45, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "ca2000.head(10)" + ] + }, + { + "cell_type": "code", + "execution_count": 46, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "ca2000.to_csv('2000_apportionment_cleaned.tsv', sep = '\\t', index=False)" + ] + }, + { + "cell_type": "code", + "execution_count": 47, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "c2_cleaned = pd.read_csv('2000_apportionment_cleaned.tsv', sep = '\\t')" + ] + }, + { + "cell_type": "code", + "execution_count": 49, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
STATEAPPORTIONMENT POPULATIONNUMBER OF APPORTIONED REPRESENTATIVES BASED ON CENSUS 2000CHANGE FROM 1990 CENSUS APPORTIONMENTTOTAL ELECTORAL VOTESNUMBER OF CITIZENS PER ELECTORAL VOTE
0ALABAMA4461130709495681
1ALASKA628933103209644
2ARIZONA51406838210514068
3ARKANSAS2679733406446622
4CALIFORNIA3393079853155616923
5COLORADO4311882719479098
6CONNECTICUT34095355-17487076
7DELAWARE785068103261689
8FLORIDA1602889025227593662
9GEORGIA820697513215547131
\n", + "
" + ], + "text/plain": [ + " STATE APPORTIONMENT POPULATION \\\n", + "0 ALABAMA 4461130 \n", + "1 ALASKA 628933 \n", + "2 ARIZONA 5140683 \n", + "3 ARKANSAS 2679733 \n", + "4 CALIFORNIA 33930798 \n", + "5 COLORADO 4311882 \n", + "6 CONNECTICUT 3409535 \n", + "7 DELAWARE 785068 \n", + "8 FLORIDA 16028890 \n", + "9 GEORGIA 8206975 \n", + "\n", + " NUMBER OF APPORTIONED REPRESENTATIVES BASED ON CENSUS 2000 \\\n", + "0 7 \n", + "1 1 \n", + "2 8 \n", + "3 4 \n", + "4 53 \n", + "5 7 \n", + "6 5 \n", + "7 1 \n", + "8 25 \n", + "9 13 \n", + "\n", + " CHANGE FROM 1990 CENSUS APPORTIONMENT TOTAL ELECTORAL VOTES \\\n", + "0 0 9 \n", + "1 0 3 \n", + "2 2 10 \n", + "3 0 6 \n", + "4 1 55 \n", + "5 1 9 \n", + "6 -1 7 \n", + "7 0 3 \n", + "8 2 27 \n", + "9 2 15 \n", + "\n", + " NUMBER OF CITIZENS PER ELECTORAL VOTE \n", + "0 495681 \n", + "1 209644 \n", + "2 514068 \n", + "3 446622 \n", + "4 616923 \n", + "5 479098 \n", + "6 487076 \n", + "7 261689 \n", + "8 593662 \n", + "9 547131 " + ] + }, + "execution_count": 49, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "c2_cleaned.head(10)" + ] + }, + { + "cell_type": "code", + "execution_count": 77, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "67" + ] + }, + "execution_count": 77, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import re\n", + "fxn = lambda x: re.sub(r'[^\\x00-\\x7f]',r'',x).strip('.').strip('\"').upper()\n", + "g = []\n", + "with open('2010_apportionment_raw.txt', newline='') as csvfile:\n", + " reader = csv.reader(csvfile, delimiter='\\t', quotechar='|')\n", + " for row in reader:\n", + " g.append([fxn(x) for x in row[:6]])\n", + " \n", + " \n", + "len(g)" + ] + }, + { + "cell_type": "code", + "execution_count": 78, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "[['U.S. DEPARTMENT OF COMMERCE', '', '', '', '', ''],\n", + " ['U.S. CENSUS BUREAU', '', '', '', '', ''],\n", + " ['', '', '', '', '', ''],\n", + " ['TABLE 1. APPORTIONMENT POPULATION AND NUMBER OF REPRESENTATIVES, BY STATE: 2010 CENSUS',\n", + " '',\n", + " '',\n", + " '',\n", + " '',\n", + " ''],\n", + " ['', '', '', '', '', ''],\n", + " ['', '', '', 'NUMBER OF APPORTIONED', '', ''],\n", + " ['', 'APPORTIONMENT', '', 'REPRESENTATIVES', '', 'CHANGE IN SEATS'],\n", + " ['', 'POPULATION', '', 'BASED ON', '', 'FROM CENSUS 2000'],\n", + " ['STATE', '(APRIL 1, 2010)', '', '2010 CENSUS', '', 'APPORTIONMENT'],\n", + " ['', '', '', '', '', '']]" + ] + }, + "execution_count": 78, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "g[:10]" + ] + }, + { + "cell_type": "code", + "execution_count": 79, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "header_names = [(g[5][x] + ' '+ g[6][x].strip() + \n", + " ' '+ g[7][x].strip() + ' ' + g[8][x].strip()).strip() for x in range(len(g[5]))]\n" + ] + }, + { + "cell_type": "code", + "execution_count": 80, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "['STATE',\n", + " 'APPORTIONMENT POPULATION (APRIL 1, 2010)',\n", + " '',\n", + " 'NUMBER OF APPORTIONED REPRESENTATIVES BASED ON 2010 CENSUS',\n", + " '',\n", + " 'CHANGE IN SEATS FROM CENSUS 2000 APPORTIONMENT']" + ] + }, + "execution_count": 80, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "header_names" + ] + }, + { + "cell_type": "code", + "execution_count": 82, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "['ALABAMA', '4,802,982', '', '7', '', '0']" + ] + }, + "execution_count": 82, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "g[11]" + ] + }, + { + "cell_type": "code", + "execution_count": 84, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "ca2010 = pd.DataFrame(g[11:11+50], columns=header_names) " + ] + }, + { + "cell_type": "code", + "execution_count": 87, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
STATEAPPORTIONMENT POPULATION (APRIL 1, 2010)NUMBER OF APPORTIONED REPRESENTATIVES BASED ON 2010 CENSUSCHANGE IN SEATS FROM CENSUS 2000 APPORTIONMENT
40SOUTH DAKOTA819,76110
41TENNESSEE6,375,43190
42TEXAS25,268,41836+4
43UTAH2,770,7654+1
44VERMONT630,33710
45VIRGINIA8,037,736110
46WASHINGTON6,753,36910+1
47WEST VIRGINIA1,859,81530
48WISCONSIN5,698,23080
49WYOMING568,30010
\n", + "
" + ], + "text/plain": [ + " STATE APPORTIONMENT POPULATION (APRIL 1, 2010) \\\n", + "40 SOUTH DAKOTA 819,761 \n", + "41 TENNESSEE 6,375,431 \n", + "42 TEXAS 25,268,418 \n", + "43 UTAH 2,770,765 \n", + "44 VERMONT 630,337 \n", + "45 VIRGINIA 8,037,736 \n", + "46 WASHINGTON 6,753,369 \n", + "47 WEST VIRGINIA 1,859,815 \n", + "48 WISCONSIN 5,698,230 \n", + "49 WYOMING 568,300 \n", + "\n", + " NUMBER OF APPORTIONED REPRESENTATIVES BASED ON 2010 CENSUS \\\n", + "40 1 \n", + "41 9 \n", + "42 36 \n", + "43 4 \n", + "44 1 \n", + "45 11 \n", + "46 10 \n", + "47 3 \n", + "48 8 \n", + "49 1 \n", + "\n", + " CHANGE IN SEATS FROM CENSUS 2000 APPORTIONMENT \n", + "40 0 \n", + "41 0 \n", + "42 +4 \n", + "43 +1 \n", + "44 0 \n", + "45 0 \n", + "46 +1 \n", + "47 0 \n", + "48 0 \n", + "49 0 " + ] + }, + "execution_count": 87, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "ca2010.tail(10)" + ] + }, + { + "cell_type": "code", + "execution_count": 88, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "ca2010 = ca2010[['STATE', 'APPORTIONMENT POPULATION (APRIL 1, 2010)',\n", + " 'NUMBER OF APPORTIONED REPRESENTATIVES BASED ON 2010 CENSUS', \n", + " 'CHANGE IN SEATS FROM CENSUS 2000 APPORTIONMENT']]" + ] + }, + { + "cell_type": "code", + "execution_count": 89, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
STATEAPPORTIONMENT POPULATION (APRIL 1, 2010)NUMBER OF APPORTIONED REPRESENTATIVES BASED ON 2010 CENSUSCHANGE IN SEATS FROM CENSUS 2000 APPORTIONMENT
0ALABAMA4,802,98270
1ALASKA721,52310
2ARIZONA6,412,7009+1
3ARKANSAS2,926,22940
4CALIFORNIA37,341,989530
5COLORADO5,044,93070
6CONNECTICUT3,581,62850
7DELAWARE900,87710
8FLORIDA18,900,77327+2
9GEORGIA9,727,56614+1
10HAWAII1,366,86220
11IDAHO1,573,49920
12ILLINOIS12,864,38018-1
13INDIANA6,501,58290
14IOWA3,053,7874-1
15KANSAS2,863,81340
16KENTUCKY4,350,60660
17LOUISIANA4,553,9626-1
18MAINE1,333,07420
19MARYLAND5,789,92980
20MASSACHUSETTS6,559,6449-1
21MICHIGAN9,911,62614-1
22MINNESOTA5,314,87980
23MISSISSIPPI2,978,24040
24MISSOURI6,011,4788-1
25MONTANA994,41610
26NEBRASKA1,831,82530
27NEVADA2,709,4324+1
28NEW HAMPSHIRE1,321,44520
29NEW JERSEY8,807,50112-1
30NEW MEXICO2,067,27330
31NEW YORK19,421,05527-2
32NORTH CAROLINA9,565,781130
33NORTH DAKOTA675,90510
34OHIO11,568,49516-2
35OKLAHOMA3,764,88250
36OREGON3,848,60650
37PENNSYLVANIA12,734,90518-1
38RHODE ISLAND1,055,24720
39SOUTH CAROLINA4,645,9757+1
40SOUTH DAKOTA819,76110
41TENNESSEE6,375,43190
42TEXAS25,268,41836+4
43UTAH2,770,7654+1
44VERMONT630,33710
45VIRGINIA8,037,736110
46WASHINGTON6,753,36910+1
47WEST VIRGINIA1,859,81530
48WISCONSIN5,698,23080
49WYOMING568,30010
\n", + "
" + ], + "text/plain": [ + " STATE APPORTIONMENT POPULATION (APRIL 1, 2010) \\\n", + "0 ALABAMA 4,802,982 \n", + "1 ALASKA 721,523 \n", + "2 ARIZONA 6,412,700 \n", + "3 ARKANSAS 2,926,229 \n", + "4 CALIFORNIA 37,341,989 \n", + "5 COLORADO 5,044,930 \n", + "6 CONNECTICUT 3,581,628 \n", + "7 DELAWARE 900,877 \n", + "8 FLORIDA 18,900,773 \n", + "9 GEORGIA 9,727,566 \n", + "10 HAWAII 1,366,862 \n", + "11 IDAHO 1,573,499 \n", + "12 ILLINOIS 12,864,380 \n", + "13 INDIANA 6,501,582 \n", + "14 IOWA 3,053,787 \n", + "15 KANSAS 2,863,813 \n", + "16 KENTUCKY 4,350,606 \n", + "17 LOUISIANA 4,553,962 \n", + "18 MAINE 1,333,074 \n", + "19 MARYLAND 5,789,929 \n", + "20 MASSACHUSETTS 6,559,644 \n", + "21 MICHIGAN 9,911,626 \n", + "22 MINNESOTA 5,314,879 \n", + "23 MISSISSIPPI 2,978,240 \n", + "24 MISSOURI 6,011,478 \n", + "25 MONTANA 994,416 \n", + "26 NEBRASKA 1,831,825 \n", + "27 NEVADA 2,709,432 \n", + "28 NEW HAMPSHIRE 1,321,445 \n", + "29 NEW JERSEY 8,807,501 \n", + "30 NEW MEXICO 2,067,273 \n", + "31 NEW YORK 19,421,055 \n", + "32 NORTH CAROLINA 9,565,781 \n", + "33 NORTH DAKOTA 675,905 \n", + "34 OHIO 11,568,495 \n", + "35 OKLAHOMA 3,764,882 \n", + "36 OREGON 3,848,606 \n", + "37 PENNSYLVANIA 12,734,905 \n", + "38 RHODE ISLAND 1,055,247 \n", + "39 SOUTH CAROLINA 4,645,975 \n", + "40 SOUTH DAKOTA 819,761 \n", + "41 TENNESSEE 6,375,431 \n", + "42 TEXAS 25,268,418 \n", + "43 UTAH 2,770,765 \n", + "44 VERMONT 630,337 \n", + "45 VIRGINIA 8,037,736 \n", + "46 WASHINGTON 6,753,369 \n", + "47 WEST VIRGINIA 1,859,815 \n", + "48 WISCONSIN 5,698,230 \n", + "49 WYOMING 568,300 \n", + "\n", + " NUMBER OF APPORTIONED REPRESENTATIVES BASED ON 2010 CENSUS \\\n", + "0 7 \n", + "1 1 \n", + "2 9 \n", + "3 4 \n", + "4 53 \n", + "5 7 \n", + "6 5 \n", + "7 1 \n", + "8 27 \n", + "9 14 \n", + "10 2 \n", + "11 2 \n", + "12 18 \n", + "13 9 \n", + "14 4 \n", + "15 4 \n", + "16 6 \n", + "17 6 \n", + "18 2 \n", + "19 8 \n", + "20 9 \n", + "21 14 \n", + "22 8 \n", + "23 4 \n", + "24 8 \n", + "25 1 \n", + "26 3 \n", + "27 4 \n", + "28 2 \n", + "29 12 \n", + "30 3 \n", + "31 27 \n", + "32 13 \n", + "33 1 \n", + "34 16 \n", + "35 5 \n", + "36 5 \n", + "37 18 \n", + "38 2 \n", + "39 7 \n", + "40 1 \n", + "41 9 \n", + "42 36 \n", + "43 4 \n", + "44 1 \n", + "45 11 \n", + "46 10 \n", + "47 3 \n", + "48 8 \n", + "49 1 \n", + "\n", + " CHANGE IN SEATS FROM CENSUS 2000 APPORTIONMENT \n", + "0 0 \n", + "1 0 \n", + "2 +1 \n", + "3 0 \n", + "4 0 \n", + "5 0 \n", + "6 0 \n", + "7 0 \n", + "8 +2 \n", + "9 +1 \n", + "10 0 \n", + "11 0 \n", + "12 -1 \n", + "13 0 \n", + "14 -1 \n", + "15 0 \n", + "16 0 \n", + "17 -1 \n", + "18 0 \n", + "19 0 \n", + "20 -1 \n", + "21 -1 \n", + "22 0 \n", + "23 0 \n", + "24 -1 \n", + "25 0 \n", + "26 0 \n", + "27 +1 \n", + "28 0 \n", + "29 -1 \n", + "30 0 \n", + "31 -2 \n", + "32 0 \n", + "33 0 \n", + "34 -2 \n", + "35 0 \n", + "36 0 \n", + "37 -1 \n", + "38 0 \n", + "39 +1 \n", + "40 0 \n", + "41 0 \n", + "42 +4 \n", + "43 +1 \n", + "44 0 \n", + "45 0 \n", + "46 +1 \n", + "47 0 \n", + "48 0 \n", + "49 0 " + ] + }, + "execution_count": 89, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "ca2010" + ] + }, + { + "cell_type": "code", + "execution_count": 93, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "ca2010['APPORTIONMENT POPULATION (APRIL 1, 2010)'] = ca2010['APPORTIONMENT POPULATION (APRIL 1, 2010)'].map(\n", + " lambda x: int(x.replace(',','')) if x != '' else 0)" + ] + }, + { + "cell_type": "code", + "execution_count": 94, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
STATEAPPORTIONMENT POPULATION (APRIL 1, 2010)NUMBER OF APPORTIONED REPRESENTATIVES BASED ON 2010 CENSUSCHANGE IN SEATS FROM CENSUS 2000 APPORTIONMENT
0ALABAMA480298270
1ALASKA72152310
2ARIZONA64127009+1
3ARKANSAS292622940
4CALIFORNIA37341989530
5COLORADO504493070
6CONNECTICUT358162850
7DELAWARE90087710
8FLORIDA1890077327+2
9GEORGIA972756614+1
\n", + "
" + ], + "text/plain": [ + " STATE APPORTIONMENT POPULATION (APRIL 1, 2010) \\\n", + "0 ALABAMA 4802982 \n", + "1 ALASKA 721523 \n", + "2 ARIZONA 6412700 \n", + "3 ARKANSAS 2926229 \n", + "4 CALIFORNIA 37341989 \n", + "5 COLORADO 5044930 \n", + "6 CONNECTICUT 3581628 \n", + "7 DELAWARE 900877 \n", + "8 FLORIDA 18900773 \n", + "9 GEORGIA 9727566 \n", + "\n", + " NUMBER OF APPORTIONED REPRESENTATIVES BASED ON 2010 CENSUS \\\n", + "0 7 \n", + "1 1 \n", + "2 9 \n", + "3 4 \n", + "4 53 \n", + "5 7 \n", + "6 5 \n", + "7 1 \n", + "8 27 \n", + "9 14 \n", + "\n", + " CHANGE IN SEATS FROM CENSUS 2000 APPORTIONMENT \n", + "0 0 \n", + "1 0 \n", + "2 +1 \n", + "3 0 \n", + "4 0 \n", + "5 0 \n", + "6 0 \n", + "7 0 \n", + "8 +2 \n", + "9 +1 " + ] + }, + "execution_count": 94, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "ca2010.head(10)" + ] + }, + { + "cell_type": "code", + "execution_count": 96, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "str" + ] + }, + "execution_count": 96, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "type(ca2010['NUMBER OF APPORTIONED REPRESENTATIVES BASED ON 2010 CENSUS'][3])" + ] + }, + { + "cell_type": "code", + "execution_count": 97, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "ca2010['NUMBER OF APPORTIONED REPRESENTATIVES BASED ON 2010 CENSUS'] = ca2010['NUMBER OF APPORTIONED REPRESENTATIVES BASED ON 2010 CENSUS'].map(\n", + " lambda x: int(x.replace(',','')) if x != '' else 0)" + ] + }, + { + "cell_type": "code", + "execution_count": 98, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "numpy.int64" + ] + }, + "execution_count": 98, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "type(ca2010['NUMBER OF APPORTIONED REPRESENTATIVES BASED ON 2010 CENSUS'][3])" + ] + }, + { + "cell_type": "code", + "execution_count": 99, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
STATEAPPORTIONMENT POPULATION (APRIL 1, 2010)NUMBER OF APPORTIONED REPRESENTATIVES BASED ON 2010 CENSUSCHANGE IN SEATS FROM CENSUS 2000 APPORTIONMENT
0ALABAMA480298270
1ALASKA72152310
2ARIZONA64127009+1
3ARKANSAS292622940
4CALIFORNIA37341989530
5COLORADO504493070
6CONNECTICUT358162850
7DELAWARE90087710
8FLORIDA1890077327+2
9GEORGIA972756614+1
\n", + "
" + ], + "text/plain": [ + " STATE APPORTIONMENT POPULATION (APRIL 1, 2010) \\\n", + "0 ALABAMA 4802982 \n", + "1 ALASKA 721523 \n", + "2 ARIZONA 6412700 \n", + "3 ARKANSAS 2926229 \n", + "4 CALIFORNIA 37341989 \n", + "5 COLORADO 5044930 \n", + "6 CONNECTICUT 3581628 \n", + "7 DELAWARE 900877 \n", + "8 FLORIDA 18900773 \n", + "9 GEORGIA 9727566 \n", + "\n", + " NUMBER OF APPORTIONED REPRESENTATIVES BASED ON 2010 CENSUS \\\n", + "0 7 \n", + "1 1 \n", + "2 9 \n", + "3 4 \n", + "4 53 \n", + "5 7 \n", + "6 5 \n", + "7 1 \n", + "8 27 \n", + "9 14 \n", + "\n", + " CHANGE IN SEATS FROM CENSUS 2000 APPORTIONMENT \n", + "0 0 \n", + "1 0 \n", + "2 +1 \n", + "3 0 \n", + "4 0 \n", + "5 0 \n", + "6 0 \n", + "7 0 \n", + "8 +2 \n", + "9 +1 " + ] + }, + "execution_count": 99, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "ca2010.head(10)" + ] + }, + { + "cell_type": "code", + "execution_count": 100, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "ca2010['TOTAL ELECTORAL VOTES'] = ca2010['NUMBER OF APPORTIONED REPRESENTATIVES BASED ON 2010 CENSUS'] + 2" + ] + }, + { + "cell_type": "code", + "execution_count": 102, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
STATEAPPORTIONMENT POPULATION (APRIL 1, 2010)NUMBER OF APPORTIONED REPRESENTATIVES BASED ON 2010 CENSUSCHANGE IN SEATS FROM CENSUS 2000 APPORTIONMENTTOTAL ELECTORAL VOTES
0ALABAMA4802982709
1ALASKA721523103
2ARIZONA64127009+111
3ARKANSAS2926229406
4CALIFORNIA3734198953055
5COLORADO5044930709
6CONNECTICUT3581628507
7DELAWARE900877103
8FLORIDA1890077327+229
9GEORGIA972756614+116
\n", + "
" + ], + "text/plain": [ + " STATE APPORTIONMENT POPULATION (APRIL 1, 2010) \\\n", + "0 ALABAMA 4802982 \n", + "1 ALASKA 721523 \n", + "2 ARIZONA 6412700 \n", + "3 ARKANSAS 2926229 \n", + "4 CALIFORNIA 37341989 \n", + "5 COLORADO 5044930 \n", + "6 CONNECTICUT 3581628 \n", + "7 DELAWARE 900877 \n", + "8 FLORIDA 18900773 \n", + "9 GEORGIA 9727566 \n", + "\n", + " NUMBER OF APPORTIONED REPRESENTATIVES BASED ON 2010 CENSUS \\\n", + "0 7 \n", + "1 1 \n", + "2 9 \n", + "3 4 \n", + "4 53 \n", + "5 7 \n", + "6 5 \n", + "7 1 \n", + "8 27 \n", + "9 14 \n", + "\n", + " CHANGE IN SEATS FROM CENSUS 2000 APPORTIONMENT TOTAL ELECTORAL VOTES \n", + "0 0 9 \n", + "1 0 3 \n", + "2 +1 11 \n", + "3 0 6 \n", + "4 0 55 \n", + "5 0 9 \n", + "6 0 7 \n", + "7 0 3 \n", + "8 +2 29 \n", + "9 +1 16 " + ] + }, + "execution_count": 102, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "ca2010.head(10)" + ] + }, + { + "cell_type": "code", + "execution_count": 103, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "ca2010['NUMBER OF CITIZENS PER ELECTORAL VOTE'] = ca2010['APPORTIONMENT POPULATION (APRIL 1, 2010)']/ca2010['TOTAL ELECTORAL VOTES']" + ] + }, + { + "cell_type": "code", + "execution_count": 104, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
STATEAPPORTIONMENT POPULATION (APRIL 1, 2010)NUMBER OF APPORTIONED REPRESENTATIVES BASED ON 2010 CENSUSCHANGE IN SEATS FROM CENSUS 2000 APPORTIONMENTTOTAL ELECTORAL VOTESNUMBER OF CITIZENS PER ELECTORAL VOTE
0ALABAMA4802982709533664.666667
1ALASKA721523103240507.666667
2ARIZONA64127009+111582972.727273
3ARKANSAS2926229406487704.833333
4CALIFORNIA3734198953055678945.254545
5COLORADO5044930709560547.777778
6CONNECTICUT3581628507511661.142857
7DELAWARE900877103300292.333333
8FLORIDA1890077327+229651750.793103
9GEORGIA972756614+116607972.875000
\n", + "
" + ], + "text/plain": [ + " STATE APPORTIONMENT POPULATION (APRIL 1, 2010) \\\n", + "0 ALABAMA 4802982 \n", + "1 ALASKA 721523 \n", + "2 ARIZONA 6412700 \n", + "3 ARKANSAS 2926229 \n", + "4 CALIFORNIA 37341989 \n", + "5 COLORADO 5044930 \n", + "6 CONNECTICUT 3581628 \n", + "7 DELAWARE 900877 \n", + "8 FLORIDA 18900773 \n", + "9 GEORGIA 9727566 \n", + "\n", + " NUMBER OF APPORTIONED REPRESENTATIVES BASED ON 2010 CENSUS \\\n", + "0 7 \n", + "1 1 \n", + "2 9 \n", + "3 4 \n", + "4 53 \n", + "5 7 \n", + "6 5 \n", + "7 1 \n", + "8 27 \n", + "9 14 \n", + "\n", + " CHANGE IN SEATS FROM CENSUS 2000 APPORTIONMENT TOTAL ELECTORAL VOTES \\\n", + "0 0 9 \n", + "1 0 3 \n", + "2 +1 11 \n", + "3 0 6 \n", + "4 0 55 \n", + "5 0 9 \n", + "6 0 7 \n", + "7 0 3 \n", + "8 +2 29 \n", + "9 +1 16 \n", + "\n", + " NUMBER OF CITIZENS PER ELECTORAL VOTE \n", + "0 533664.666667 \n", + "1 240507.666667 \n", + "2 582972.727273 \n", + "3 487704.833333 \n", + "4 678945.254545 \n", + "5 560547.777778 \n", + "6 511661.142857 \n", + "7 300292.333333 \n", + "8 651750.793103 \n", + "9 607972.875000 " + ] + }, + "execution_count": 104, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "ca2010.head(10)" + ] + }, + { + "cell_type": "code", + "execution_count": 105, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "ca2010['NUMBER OF CITIZENS PER ELECTORAL VOTE'] = ca2010['NUMBER OF CITIZENS PER ELECTORAL VOTE'].map(lambda x: int(x))" + ] + }, + { + "cell_type": "code", + "execution_count": 106, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
STATEAPPORTIONMENT POPULATION (APRIL 1, 2010)NUMBER OF APPORTIONED REPRESENTATIVES BASED ON 2010 CENSUSCHANGE IN SEATS FROM CENSUS 2000 APPORTIONMENTTOTAL ELECTORAL VOTESNUMBER OF CITIZENS PER ELECTORAL VOTE
0ALABAMA4802982709533664
1ALASKA721523103240507
2ARIZONA64127009+111582972
3ARKANSAS2926229406487704
4CALIFORNIA3734198953055678945
5COLORADO5044930709560547
6CONNECTICUT3581628507511661
7DELAWARE900877103300292
8FLORIDA1890077327+229651750
9GEORGIA972756614+116607972
\n", + "
" + ], + "text/plain": [ + " STATE APPORTIONMENT POPULATION (APRIL 1, 2010) \\\n", + "0 ALABAMA 4802982 \n", + "1 ALASKA 721523 \n", + "2 ARIZONA 6412700 \n", + "3 ARKANSAS 2926229 \n", + "4 CALIFORNIA 37341989 \n", + "5 COLORADO 5044930 \n", + "6 CONNECTICUT 3581628 \n", + "7 DELAWARE 900877 \n", + "8 FLORIDA 18900773 \n", + "9 GEORGIA 9727566 \n", + "\n", + " NUMBER OF APPORTIONED REPRESENTATIVES BASED ON 2010 CENSUS \\\n", + "0 7 \n", + "1 1 \n", + "2 9 \n", + "3 4 \n", + "4 53 \n", + "5 7 \n", + "6 5 \n", + "7 1 \n", + "8 27 \n", + "9 14 \n", + "\n", + " CHANGE IN SEATS FROM CENSUS 2000 APPORTIONMENT TOTAL ELECTORAL VOTES \\\n", + "0 0 9 \n", + "1 0 3 \n", + "2 +1 11 \n", + "3 0 6 \n", + "4 0 55 \n", + "5 0 9 \n", + "6 0 7 \n", + "7 0 3 \n", + "8 +2 29 \n", + "9 +1 16 \n", + "\n", + " NUMBER OF CITIZENS PER ELECTORAL VOTE \n", + "0 533664 \n", + "1 240507 \n", + "2 582972 \n", + "3 487704 \n", + "4 678945 \n", + "5 560547 \n", + "6 511661 \n", + "7 300292 \n", + "8 651750 \n", + "9 607972 " + ] + }, + "execution_count": 106, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "ca2010.head(10)" + ] + }, + { + "cell_type": "code", + "execution_count": 107, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "ca2010.to_csv('2010_apportionment_cleaned.tsv', sep = '\\t', index=False)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] + } + ], + "metadata": { + "anaconda-cloud": {}, + "kernelspec": { + "display_name": "Python [Root]", + "language": "python", + "name": "Python [Root]" + }, + "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": 2 +} diff --git a/data-raw/1990_apportionment_cleaned.tsv b/data-raw/1990_apportionment_cleaned.tsv new file mode 100644 index 0000000..56c9c05 --- /dev/null +++ b/data-raw/1990_apportionment_cleaned.tsv @@ -0,0 +1,52 @@ +STATES SIZE OF STATE DELEGATION APPORTIONMENT POPULATION RESIDENT POPULATION UNITED STATES POPULATION ABROAD TOTAL ELECTORAL VOTES NUMBER OF CITIZENS PER ELECTORAL VOTE +ALABAMA 7 4062608 4040587 22021 9 451400 +ALASKA 1 551947 550043 1904 3 183982 +ARIZONA 6 3677985 3665228 12757 8 459748 +ARKANSAS 4 2362239 2350725 11514 6 393706 +CALIFORNIA 52 29839250 29760021 79229 54 552578 +COLORADO 6 3307912 3294394 13518 8 413489 +CONNECTICUT 6 3295669 3287116 8553 8 411958 +DELAWARE 1 668696 666168 2528 3 222898 +DISTRICT OF COLUMBIA 0 0 606900 3009 3 203303 +FLORIDA 23 13003362 12937926 65436 25 520134 +GEORGIA 11 6508419 6478216 30203 13 500647 +HAWAII 2 1115274 1108229 7045 4 278818 +IDAHO 2 1011986 1006749 5237 4 252996 +ILLINOIS 20 11466682 11430602 36080 22 521212 +INDIANA 10 5564228 5544159 20069 12 463685 +IOWA 5 2787424 2776755 10669 7 398203 +KANSAS 4 2485600 2477574 8026 6 414266 +KENTUCKY 6 3698969 3685296 13673 8 462371 +LOUISIANA 7 4238216 4219973 18243 9 470912 +MAINE 2 1233223 1227928 5295 4 308305 +MARYLAND 8 4798622 4781468 17154 10 479862 +MASSACHUSETTS 10 6029051 6016425 12626 12 502420 +MICHIGAN 16 9328784 9295297 33487 18 518265 +MINNESOTA 8 4387029 4375099 11930 10 438702 +MISSISSIPPI 5 2586443 2573216 13227 7 369491 +MISSOURI 9 5137804 5117073 20731 11 467073 +MONTANA 1 803655 799065 4590 3 267885 +NEBRASKA 3 1584617 1578385 6232 5 316923 +NEVADA 2 1206152 1201833 4319 4 301538 +NEW HAMPSHIRE 2 1113915 1109252 4663 4 278478 +NEW JERSEY 13 7748634 7730188 18446 15 516575 +NEW MEXICO 3 1521779 1515069 6710 5 304355 +NEW YORK 31 18044505 17990455 54050 33 546803 +NORTH CAROLINA 12 6657630 6628637 28993 14 475545 +NORTH DAKOTA 1 641364 638800 2564 3 213788 +OHIO 19 10887325 10847115 40210 21 518444 +OKLAHOMA 6 3157604 3145585 12019 8 394700 +OREGON 5 2853733 2842321 11412 7 407676 +PENNSYLVANIA 21 11924710 11881643 43067 23 518465 +RHODE ISLAND 2 1005984 1003464 2520 4 251496 +SOUTH CAROLINA 6 3505707 3486703 19004 8 438213 +SOUTH DAKOTA 1 699999 696004 3995 3 233333 +TENNESSEE 9 4896641 4877185 19456 11 445149 +TEXAS 30 17059805 16986510 73295 32 533118 +UTAH 3 1727784 1722850 4934 5 345556 +VERMONT 1 564964 562758 2206 3 188321 +VIRGINIA 11 6216568 6187358 29210 13 478197 +WASHINGTON 9 4887941 4866692 21249 11 444358 +WEST VIRGINIA 3 1801625 1793477 8148 5 360325 +WISCONSIN 9 4906745 4891769 14976 11 446067 +WYOMING 1 455975 453588 2387 3 151991 diff --git a/data-raw/1990_apportionment_raw.csv b/data-raw/1990_apportionment_raw.csv new file mode 100644 index 0000000..f496f68 --- /dev/null +++ b/data-raw/1990_apportionment_raw.csv @@ -0,0 +1 @@ +Table A. Apportionment and Apportionment Population Based on the 1990 Census,,,,,, ,,,,,, States ,Size of State,Apportionment,,United States,, ,delegation,population,Resident population,population abroad,, ,,,,,, United States ,435,"1 249,022,783","248,709,873","922,819",, ,,,,,, Alabama……………………………………..,7,"4,062,608","4,040,587","22,021",, Alaska……………………………………..,1,"551,947","550,043","1,904",, Arizona……………………………………..,6,"3,677,985","3,665,228","12,757",, Arkansas……………………………………..,4,"2,362,239","2,350,725","11,514",, California……………………………………..,52,"29,839,250","29,760,021","79,229",, Colorado……………………………………..,6,"3,307,912","3,294,394","13,518",, Connecticut……………………………………..,6,"3,295,669","3,287,116","8,553",, Delaware……………………………………..,1,"668,696","666,168","2,528",, District of Columbia……………………………………..,...,…,"606,900","3,009",, Florida……………………………………..,23,"13,003,362","12,937,926","65,436",, Georgia……………………………………..,11,"6,508,419","6,478,216","30,203",, Hawaii……………………………………..,2,"1,115,274","1,108,229","7,045",, Idaho……………………………………..,2,"1,011,986","1,006,749","5,237",, Illinois……………………………………..,20,"11,466,682","11,430,602","36,080",, Indiana……………………………………..,10,"5,564,228","5,544,159","20,069",, Iowa……………………………………..,5,"2,787,424","2,776,755","10,669",, Kansas……………………………………..,4,"2,485,600","2,477,574","8,026",, Kentucky……………………………………..,6,"3,698,969","3,685,296","13,673",, Louisiana……………………………………..,7,"4,238,216","4,219,973","18,243",, Maine……………………………………..,2,"1,233,223","1,227,928","5,295",, Maryland……………………………………..,8,"4,798,622","4,781,468","17,154",, Massachusetts……………………………………..,10,"6,029,051","6,016,425","12,626",, Michigan……………………………………..,16,"9,328,784","9,295,297","33,487",, Minnesota……………………………………..,8,"4,387,029","4,375,099","11,930",, Mississippi……………………………………..,5,"2,586,443","2,573,216","13,227",, Missouri……………………………………..,9,"5,137,804","5,117,073","20,731",, Montana……………………………………..,1,"803,655","799,065","4,590",, Nebraska……………………………………..,3,"1,584,617","1,578,385","6,232",, Nevada……………………………………..,2,"1,206,152","1,201,833","4,319",, New Hampshire……………………………………..,2,"1,113,915","1,109,252","4,663",, New Jersey……………………………………..,13,"7,748,634","7,730,188","18,446",, New Mexico……………………………………..,3,"1,521,779","1,515,069","6,710",, New York……………………………………..,31,"18,044,505","17,990,455","54,050",, North Carolina……………………………………..,12,"6,657,630","6,628,637","28,993",, North Dakota……………………………………..,1,"641,364","638,800","2,564",, Ohio……………………………………..,19,"10,887,325","10,847,115","40,210",, Oklahoma……………………………………..,6,"3,157,604","3,145,585","12,019",, Oregon……………………………………..,5,"2,853,733","2,842,321","11,412",, Pennsylvania……………………………………..,21,"11,924,710","11,881,643","43,067",, Rhode Island……………………………………..,2,"1,005,984","1,003,464","2,520",, South Carolina……………………………………..,6,"3,505,707","3,486,703","19,004",, South Dakota……………………………………..,1,"699,999","696,004","3,995",, Tennessee……………………………………..,9,"4,896,641","4,877,185","19,456",, Texas……………………………………..,30,"17,059,805","16,986,510","73,295",, Utah……………………………………..,3,"1,727,784","1,722,850","4,934",, Vermont……………………………………..,1,"564,964","562,758","2,206",, Virginia……………………………………..,11,"6,216,568","6,187,358","29,210",, Washington……………………………………..,9,"4,887,941","4,866,692","21,249",, West Virginia……………………………………..,3,"1,801,625","1,793,477","8,148",, Wisconsin……………………………………..,9,"4,906,745","4,891,769","14,976",, Wyoming……………………………………..,1,"455,975","453,588","2,387",, ,,,,,, 1 The apportionment population does not include the resident or the overseas population for the District of Columbia,,,,,, \ No newline at end of file diff --git a/data-raw/1990_apportionment_raw.txt b/data-raw/1990_apportionment_raw.txt new file mode 100644 index 0000000..82b135d --- /dev/null +++ b/data-raw/1990_apportionment_raw.txt @@ -0,0 +1 @@ +Table A. Apportionment and Apportionment Population Based on the 1990 Census States Size of State Apportionment United States delegation population Resident population population abroad United States 435 "1 249,022,783" "248,709,873" "922,819" AlabamaÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 7 "4,062,608" "4,040,587" "22,021" AlaskaÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 1 "551,947" "550,043" "1,904" ArizonaÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 6 "3,677,985" "3,665,228" "12,757" ArkansasÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 4 "2,362,239" "2,350,725" "11,514" CaliforniaÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 52 "29,839,250" "29,760,021" "79,229" ColoradoÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 6 "3,307,912" "3,294,394" "13,518" ConnecticutÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 6 "3,295,669" "3,287,116" "8,553" DelawareÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 1 "668,696" "666,168" "2,528" District of ColumbiaÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. ... É "606,900" "3,009" FloridaÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 23 "13,003,362" "12,937,926" "65,436" GeorgiaÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 11 "6,508,419" "6,478,216" "30,203" HawaiiÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 2 "1,115,274" "1,108,229" "7,045" IdahoÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 2 "1,011,986" "1,006,749" "5,237" IllinoisÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 20 "11,466,682" "11,430,602" "36,080" IndianaÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 10 "5,564,228" "5,544,159" "20,069" IowaÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 5 "2,787,424" "2,776,755" "10,669" KansasÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 4 "2,485,600" "2,477,574" "8,026" KentuckyÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 6 "3,698,969" "3,685,296" "13,673" LouisianaÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 7 "4,238,216" "4,219,973" "18,243" MaineÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 2 "1,233,223" "1,227,928" "5,295" MarylandÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 8 "4,798,622" "4,781,468" "17,154" MassachusettsÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 10 "6,029,051" "6,016,425" "12,626" MichiganÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 16 "9,328,784" "9,295,297" "33,487" MinnesotaÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 8 "4,387,029" "4,375,099" "11,930" MississippiÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 5 "2,586,443" "2,573,216" "13,227" MissouriÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 9 "5,137,804" "5,117,073" "20,731" MontanaÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 1 "803,655" "799,065" "4,590" NebraskaÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 3 "1,584,617" "1,578,385" "6,232" NevadaÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 2 "1,206,152" "1,201,833" "4,319" New HampshireÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 2 "1,113,915" "1,109,252" "4,663" New JerseyÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 13 "7,748,634" "7,730,188" "18,446" New MexicoÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 3 "1,521,779" "1,515,069" "6,710" New YorkÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 31 "18,044,505" "17,990,455" "54,050" North CarolinaÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 12 "6,657,630" "6,628,637" "28,993" North DakotaÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 1 "641,364" "638,800" "2,564" OhioÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 19 "10,887,325" "10,847,115" "40,210" OklahomaÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 6 "3,157,604" "3,145,585" "12,019" OregonÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 5 "2,853,733" "2,842,321" "11,412" PennsylvaniaÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 21 "11,924,710" "11,881,643" "43,067" Rhode IslandÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 2 "1,005,984" "1,003,464" "2,520" South CarolinaÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 6 "3,505,707" "3,486,703" "19,004" South DakotaÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 1 "699,999" "696,004" "3,995" TennesseeÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 9 "4,896,641" "4,877,185" "19,456" TexasÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 30 "17,059,805" "16,986,510" "73,295" UtahÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 3 "1,727,784" "1,722,850" "4,934" VermontÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 1 "564,964" "562,758" "2,206" VirginiaÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 11 "6,216,568" "6,187,358" "29,210" WashingtonÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 9 "4,887,941" "4,866,692" "21,249" West VirginiaÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 3 "1,801,625" "1,793,477" "8,148" WisconsinÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 9 "4,906,745" "4,891,769" "14,976" WyomingÉÉÉÉÉÉÉÉÉÉÉÉÉÉ.. 1 "455,975" "453,588" "2,387" 1 The apportionment population does not include the resident or the overseas population for the District of Columbia \ No newline at end of file diff --git a/data-raw/2000_apportionment_cleaned.tsv b/data-raw/2000_apportionment_cleaned.tsv new file mode 100644 index 0000000..4ae2f3c --- /dev/null +++ b/data-raw/2000_apportionment_cleaned.tsv @@ -0,0 +1,51 @@ +STATE APPORTIONMENT POPULATION NUMBER OF APPORTIONED REPRESENTATIVES BASED ON CENSUS 2000 CHANGE FROM 1990 CENSUS APPORTIONMENT TOTAL ELECTORAL VOTES NUMBER OF CITIZENS PER ELECTORAL VOTE + ALABAMA 4461130 7 0 9 495681 + ALASKA 628933 1 0 3 209644 + ARIZONA 5140683 8 +2 10 514068 + ARKANSAS 2679733 4 0 6 446622 + CALIFORNIA 33930798 53 +1 55 616923 + COLORADO 4311882 7 +1 9 479098 + CONNECTICUT 3409535 5 -1 7 487076 + DELAWARE 785068 1 0 3 261689 + FLORIDA 16028890 25 +2 27 593662 + GEORGIA 8206975 13 +2 15 547131 + HAWAII 1216642 2 0 4 304160 + IDAHO 1297274 2 0 4 324318 + ILLINOIS 12439042 19 -1 21 592335 + INDIANA 6090782 9 -1 11 553707 + IOWA 2931923 5 0 7 418846 + KANSAS 2693824 4 0 6 448970 + KENTUCKY 4049431 6 0 8 506178 + LOUISIANA 4480271 7 0 9 497807 + MAINE 1277731 2 0 4 319432 + MARYLAND 5307886 8 0 10 530788 + MASSACHUSETTS 6355568 10 0 12 529630 + MICHIGAN 9955829 15 -1 17 585637 + MINNESOTA 4925670 8 0 10 492567 + MISSISSIPPI 2852927 4 -1 6 475487 + MISSOURI 5606260 9 0 11 509660 + MONTANA 905316 1 0 3 301772 + NEBRASKA 1715369 3 0 5 343073 + NEVADA 2002032 3 +1 5 400406 + NEW HAMPSHIRE 1238415 2 0 4 309603 + NEW JERSEY 8424354 13 0 15 561623 + NEW MEXICO 1823821 3 0 5 364764 + NEW YORK 19004973 29 -2 31 613063 + NORTH CAROLINA 8067673 13 +1 15 537844 + NORTH DAKOTA 643756 1 0 3 214585 + OHIO 11374540 18 -1 20 568727 + OKLAHOMA 3458819 5 -1 7 494117 + OREGON 3428543 5 0 7 489791 + PENNSYLVANIA 12300670 19 -2 21 585746 + RHODE ISLAND 1049662 2 0 4 262415 + SOUTH CAROLINA 4025061 6 0 8 503132 + SOUTH DAKOTA 756874 1 0 3 252291 + TENNESSEE 5700037 9 0 11 518185 + TEXAS 20903994 32 +2 34 614823 + UTAH 2236714 3 0 5 447342 + VERMONT 609890 1 0 3 203296 + VIRGINIA 7100702 11 0 13 546207 + WASHINGTON 5908684 9 0 11 537153 + WEST VIRGINIA 1813077 3 0 5 362615 + WISCONSIN 5371210 8 -1 10 537121 + WYOMING 495304 1 0 3 165101 diff --git a/data-raw/2000_apportionment_raw.txt b/data-raw/2000_apportionment_raw.txt new file mode 100644 index 0000000..9984a4b --- /dev/null +++ b/data-raw/2000_apportionment_raw.txt @@ -0,0 +1 @@ +"Table 1. Apportionment Population and Number of Representatives, by State: Census 2000" State Apportionment Population Number of Apportioned Representatives Based on Census 2000 Change From 1990 Census Apportionment Alabama "4,461,130" 7 0 Alaska "628,933" 1 0 Arizona "5,140,683" 8 +2 Arkansas "2,679,733" 4 0 California "33,930,798" 53 +1 Colorado "4,311,882" 7 +1 Connecticut "3,409,535" 5 -1 Delaware "785,068" 1 0 Florida "16,028,890" 25 +2 Georgia "8,206,975" 13 +2 Hawaii "1,216,642" 2 0 Idaho "1,297,274" 2 0 Illinois "12,439,042" 19 -1 Indiana "6,090,782" 9 -1 Iowa "2,931,923" 5 0 Kansas "2,693,824" 4 0 Kentucky "4,049,431" 6 0 Louisiana "4,480,271" 7 0 Maine "1,277,731" 2 0 Maryland "5,307,886" 8 0 Massachusetts "6,355,568" 10 0 Michigan "9,955,829" 15 -1 Minnesota "4,925,670" 8 0 Mississippi "2,852,927" 4 -1 Missouri "5,606,260" 9 0 Montana "905,316" 1 0 Nebraska "1,715,369" 3 0 Nevada "2,002,032" 3 +1 New Hampshire "1,238,415" 2 0 New Jersey "8,424,354" 13 0 New Mexico "1,823,821" 3 0 New York "19,004,973" 29 -2 North Carolina "8,067,673" 13 +1 North Dakota "643,756" 1 0 Ohio "11,374,540" 18 -1 Oklahoma "3,458,819" 5 -1 Oregon "3,428,543" 5 0 Pennsylvania "12,300,670" 19 -2 Rhode Island "1,049,662" 2 0 South Carolina "4,025,061" 6 0 South Dakota "756,874" 1 0 Tennessee "5,700,037" 9 0 Texas "20,903,994" 32 +2 Utah "2,236,714" 3 0 Vermont "609,890" 1 0 Virginia "7,100,702" 11 0 Washington "5,908,684" 9 0 West Virginia "1,813,077" 3 0 Wisconsin "5,371,210" 8 -1 Wyoming "495,304" 1 0 Total Apportionment Population1 "281,424,177" 435 "1 Includes the resident population for the 50 states, as ascertained by the Twenty-Second Decennial Census under Title 13," "United States Code, and counts of overseas U.S. military and federal civilian employees (and their dependents living with them) " "allocated to their home state, as reported by the employing federal agencies. The apportionment population excludes the population" of the District of Columbia. "NOTE: As required by the January 1999 U.S. Supreme Court ruling (Department of Commerce v. House of Representatives, " "525 U.S. 316, 119 S. Ct. 765 (1999)), the apportionment population counts do not reflect the use of statistical sampling to correct" for overcounting or undercounting. "Source: U.S. Department of Commerce, U.S. Census Bureau." "Internet Release date: December 28, 2000" \ No newline at end of file diff --git a/data-raw/2000_approtionment_raw.csv b/data-raw/2000_approtionment_raw.csv new file mode 100644 index 0000000..7f34880 --- /dev/null +++ b/data-raw/2000_approtionment_raw.csv @@ -0,0 +1 @@ +"Table 1. Apportionment Population and Number of Representatives, by State: Census 2000",,,,, ,,,,, State,Apportionment Population,Number of Apportioned Representatives Based on Census 2000,Change From 1990 Census Apportionment,, ,,,,, ,,,,, ,,,,, Alabama,"4,461,130",7,0,, Alaska,"628,933",1,0,, Arizona,"5,140,683",8,+2,, Arkansas,"2,679,733",4,0,, California,"33,930,798",53,+1,, Colorado,"4,311,882",7,+1,, Connecticut,"3,409,535",5,-1,, Delaware,"785,068",1,0,, Florida,"16,028,890",25,+2,, Georgia,"8,206,975",13,+2,, Hawaii,"1,216,642",2,0,, Idaho,"1,297,274",2,0,, Illinois,"12,439,042",19,-1,, Indiana,"6,090,782",9,-1,, Iowa,"2,931,923",5,0,, Kansas,"2,693,824",4,0,, Kentucky,"4,049,431",6,0,, Louisiana,"4,480,271",7,0,, Maine,"1,277,731",2,0,, Maryland,"5,307,886",8,0,, Massachusetts,"6,355,568",10,0,, Michigan,"9,955,829",15,-1,, Minnesota,"4,925,670",8,0,, Mississippi,"2,852,927",4,-1,, Missouri,"5,606,260",9,0,, Montana,"905,316",1,0,, Nebraska,"1,715,369",3,0,, Nevada,"2,002,032",3,+1,, New Hampshire,"1,238,415",2,0,, New Jersey,"8,424,354",13,0,, New Mexico,"1,823,821",3,0,, New York,"19,004,973",29,-2,, North Carolina,"8,067,673",13,+1,, North Dakota,"643,756",1,0,, Ohio,"11,374,540",18,-1,, Oklahoma,"3,458,819",5,-1,, Oregon,"3,428,543",5,0,, Pennsylvania,"12,300,670",19,-2,, Rhode Island,"1,049,662",2,0,, South Carolina,"4,025,061",6,0,, South Dakota,"756,874",1,0,, Tennessee,"5,700,037",9,0,, Texas,"20,903,994",32,+2,, Utah,"2,236,714",3,0,, Vermont,"609,890",1,0,, Virginia,"7,100,702",11,0,, Washington,"5,908,684",9,0,, West Virginia,"1,813,077",3,0,, Wisconsin,"5,371,210",8,-1,, Wyoming,"495,304",1,0,, ,,,,, Total Apportionment Population1,"281,424,177",435,,, ,,,,, "1 Includes the resident population for the 50 states, as ascertained by the Twenty-Second Decennial Census under Title 13,",,,,, "United States Code, and counts of overseas U.S. military and federal civilian employees (and their dependents living with them) ",,,,, "allocated to their home state, as reported by the employing federal agencies. The apportionment population excludes the population",,,,, of the District of Columbia.,,,,, "NOTE: As required by the January 1999 U.S. Supreme Court ruling (Department of Commerce v. House of Representatives, ",,,,, "525 U.S. 316, 119 S. Ct. 765 (1999)), the apportionment population counts do not reflect the use of statistical sampling to correct",,,,, for overcounting or undercounting.,,,,, "Source: U.S. Department of Commerce, U.S. Census Bureau.",,,,, "Internet Release date: December 28, 2000",,,,, \ No newline at end of file diff --git a/data-raw/2010_apportionment_cleaned.tsv b/data-raw/2010_apportionment_cleaned.tsv new file mode 100644 index 0000000..380be10 --- /dev/null +++ b/data-raw/2010_apportionment_cleaned.tsv @@ -0,0 +1,51 @@ +STATE APPORTIONMENT POPULATION (APRIL 1, 2010) NUMBER OF APPORTIONED REPRESENTATIVES BASED ON 2010 CENSUS CHANGE IN SEATS FROM CENSUS 2000 APPORTIONMENT TOTAL ELECTORAL VOTES NUMBER OF CITIZENS PER ELECTORAL VOTE +ALABAMA 4802982 7 0 9 533664 +ALASKA 721523 1 0 3 240507 +ARIZONA 6412700 9 +1 11 582972 +ARKANSAS 2926229 4 0 6 487704 +CALIFORNIA 37341989 53 0 55 678945 +COLORADO 5044930 7 0 9 560547 +CONNECTICUT 3581628 5 0 7 511661 +DELAWARE 900877 1 0 3 300292 +FLORIDA 18900773 27 +2 29 651750 +GEORGIA 9727566 14 +1 16 607972 +HAWAII 1366862 2 0 4 341715 +IDAHO 1573499 2 0 4 393374 +ILLINOIS 12864380 18 -1 20 643219 +INDIANA 6501582 9 0 11 591052 +IOWA 3053787 4 -1 6 508964 +KANSAS 2863813 4 0 6 477302 +KENTUCKY 4350606 6 0 8 543825 +LOUISIANA 4553962 6 -1 8 569245 +MAINE 1333074 2 0 4 333268 +MARYLAND 5789929 8 0 10 578992 +MASSACHUSETTS 6559644 9 -1 11 596331 +MICHIGAN 9911626 14 -1 16 619476 +MINNESOTA 5314879 8 0 10 531487 +MISSISSIPPI 2978240 4 0 6 496373 +MISSOURI 6011478 8 -1 10 601147 +MONTANA 994416 1 0 3 331472 +NEBRASKA 1831825 3 0 5 366365 +NEVADA 2709432 4 +1 6 451572 +NEW HAMPSHIRE 1321445 2 0 4 330361 +NEW JERSEY 8807501 12 -1 14 629107 +NEW MEXICO 2067273 3 0 5 413454 +NEW YORK 19421055 27 -2 29 669691 +NORTH CAROLINA 9565781 13 0 15 637718 +NORTH DAKOTA 675905 1 0 3 225301 +OHIO 11568495 16 -2 18 642694 +OKLAHOMA 3764882 5 0 7 537840 +OREGON 3848606 5 0 7 549800 +PENNSYLVANIA 12734905 18 -1 20 636745 +RHODE ISLAND 1055247 2 0 4 263811 +SOUTH CAROLINA 4645975 7 +1 9 516219 +SOUTH DAKOTA 819761 1 0 3 273253 +TENNESSEE 6375431 9 0 11 579584 +TEXAS 25268418 36 +4 38 664958 +UTAH 2770765 4 +1 6 461794 +VERMONT 630337 1 0 3 210112 +VIRGINIA 8037736 11 0 13 618287 +WASHINGTON 6753369 10 +1 12 562780 +WEST VIRGINIA 1859815 3 0 5 371963 +WISCONSIN 5698230 8 0 10 569823 +WYOMING 568300 1 0 3 189433 diff --git a/data-raw/2010_apportionment_raw.csv b/data-raw/2010_apportionment_raw.csv new file mode 100644 index 0000000..589893c --- /dev/null +++ b/data-raw/2010_apportionment_raw.csv @@ -0,0 +1 @@ +U.S. Department of Commerce,,,,,,, U.S. Census Bureau,,,,,,, ,,,,,,, "Table 1. APPORTIONMENT POPULATION AND NUMBER OF REPRESENTATIVES, BY STATE: 2010 CENSUS",,,,,,, ,,,,,,, ,,,NUMBER OF APPORTIONED,,,, ,APPORTIONMENT,,REPRESENTATIVES,,CHANGE IN SEATS,, ,POPULATION,,BASED ON,,FROM CENSUS 2000,, STATE,"(APRIL 1, 2010)",,2010 CENSUS,,APPORTIONMENT,, ,,,,,,, ,,,,,,, Alabama,"4,802,982",,7,,0,, Alaska,"721,523",,1,,0,, Arizona,"6,412,700",,9,,+1,, Arkansas,"2,926,229",,4,,0,, California,"37,341,989",,53,,0,, Colorado,"5,044,930",,7,,0,, Connecticut,"3,581,628",,5,,0,, Delaware,"900,877",,1,,0,, Florida,"18,900,773",,27,,+2,, Georgia,"9,727,566",,14,,+1,, Hawaii,"1,366,862",,2,,0,, Idaho,"1,573,499",,2,,0,, Illinois,"12,864,380",,18,,-1,, Indiana,"6,501,582",,9,,0,, Iowa,"3,053,787",,4,,-1,, Kansas,"2,863,813",,4,,0,, Kentucky,"4,350,606",,6,,0,, Louisiana,"4,553,962",,6,,-1,, Maine,"1,333,074",,2,,0,, Maryland,"5,789,929",,8,,0,, Massachusetts,"6,559,644",,9,,-1,, Michigan,"9,911,626",,14,,-1,, Minnesota,"5,314,879",,8,,0,, Mississippi,"2,978,240",,4,,0,, Missouri,"6,011,478",,8,,-1,, Montana,"994,416",,1,,0,, Nebraska,"1,831,825",,3,,0,, Nevada,"2,709,432",,4,,+1,, New Hampshire,"1,321,445",,2,,0,, New Jersey,"8,807,501",,12,,-1,, New Mexico,"2,067,273",,3,,0,, New York,"19,421,055",,27,,-2,, North Carolina,"9,565,781",,13,,0,, North Dakota,"675,905",,1,,0,, Ohio,"11,568,495",,16,,-2,, Oklahoma,"3,764,882",,5,,0,, Oregon,"3,848,606",,5,,0,, Pennsylvania,"12,734,905",,18,,-1,, Rhode Island,"1,055,247",,2,,0,, South Carolina,"4,645,975",,7,,+1,, South Dakota,"819,761",,1,,0,, Tennessee,"6,375,431",,9,,0,, Texas,"25,268,418",,36,,+4,, Utah,"2,770,765",,4,,+1,, Vermont,"630,337",,1,,0,, Virginia,"8,037,736",,11,,0,, Washington,"6,753,369",,10,,+1,, West Virginia,"1,859,815",,3,,0,, Wisconsin,"5,698,230",,8,,0,, Wyoming,"568,300",,1,,0,, TOTAL1,"309,183,463",,435,,,, ,,,,,,, " 1 Apportionment population includes the resident population for the 50 states, as ascertained by the Twenty-Third",,,,,,, "Decennial Census under Title 13, United States Code, and counts of overseas U.S. military and federal ",,,,,,, "civilian employees (and their dependents living with them) allocated to their home state, as reported by",,,,,,, the employing federal agencies. The apportionment population excludes the population of the District of Columbia.,,,,,,, \ No newline at end of file diff --git a/data-raw/2010_apportionment_raw.txt b/data-raw/2010_apportionment_raw.txt new file mode 100644 index 0000000..4e1260b --- /dev/null +++ b/data-raw/2010_apportionment_raw.txt @@ -0,0 +1 @@ +U.S. Department of Commerce U.S. Census Bureau "Table 1. APPORTIONMENT POPULATION AND NUMBER OF REPRESENTATIVES, BY STATE: 2010 CENSUS" NUMBER OF APPORTIONED APPORTIONMENT REPRESENTATIVES CHANGE IN SEATS POPULATION BASED ON FROM CENSUS 2000 STATE "(APRIL 1, 2010)" 2010 CENSUS APPORTIONMENT Alabama "4,802,982" 7 0 Alaska "721,523" 1 0 Arizona "6,412,700" 9 +1 Arkansas "2,926,229" 4 0 California "37,341,989" 53 0 Colorado "5,044,930" 7 0 Connecticut "3,581,628" 5 0 Delaware "900,877" 1 0 Florida "18,900,773" 27 +2 Georgia "9,727,566" 14 +1 Hawaii "1,366,862" 2 0 Idaho "1,573,499" 2 0 Illinois "12,864,380" 18 -1 Indiana "6,501,582" 9 0 Iowa "3,053,787" 4 -1 Kansas "2,863,813" 4 0 Kentucky "4,350,606" 6 0 Louisiana "4,553,962" 6 -1 Maine "1,333,074" 2 0 Maryland "5,789,929" 8 0 Massachusetts "6,559,644" 9 -1 Michigan "9,911,626" 14 -1 Minnesota "5,314,879" 8 0 Mississippi "2,978,240" 4 0 Missouri "6,011,478" 8 -1 Montana "994,416" 1 0 Nebraska "1,831,825" 3 0 Nevada "2,709,432" 4 +1 New Hampshire "1,321,445" 2 0 New Jersey "8,807,501" 12 -1 New Mexico "2,067,273" 3 0 New York "19,421,055" 27 -2 North Carolina "9,565,781" 13 0 North Dakota "675,905" 1 0 Ohio "11,568,495" 16 -2 Oklahoma "3,764,882" 5 0 Oregon "3,848,606" 5 0 Pennsylvania "12,734,905" 18 -1 Rhode Island "1,055,247" 2 0 South Carolina "4,645,975" 7 +1 South Dakota "819,761" 1 0 Tennessee "6,375,431" 9 0 Texas "25,268,418" 36 +4 Utah "2,770,765" 4 +1 Vermont "630,337" 1 0 Virginia "8,037,736" 11 0 Washington "6,753,369" 10 +1 West Virginia "1,859,815" 3 0 Wisconsin "5,698,230" 8 0 Wyoming "568,300" 1 0 TOTAL1 "309,183,463" 435 " 1 Apportionment population includes the resident population for the 50 states, as ascertained by the Twenty-Third" "Decennial Census under Title 13, United States Code, and counts of overseas U.S. military and federal " "civilian employees (and their dependents living with them) allocated to their home state, as reported by" the employing federal agencies. The apportionment population excludes the population of the District of Columbia. \ No newline at end of file diff --git a/data-raw/appropriation_cleanup.ipynb b/data-raw/appropriation_cleanup.ipynb new file mode 100644 index 0000000..b303959 --- /dev/null +++ b/data-raw/appropriation_cleanup.ipynb @@ -0,0 +1,4701 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "'3.5.2 |Anaconda 4.1.1 (x86_64)| (default, Jul 2 2016, 17:52:12) \\n[GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)]'" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import numpy as np\n", + "import pandas as pd\n", + "import sys\n", + "sys.version" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0 Table A. Apportionment and Apportionment Population Based on the 1990 Census,,,,,,\n", + "\n", + "1 ,,,,,,\n", + "\n", + "2 States ,Size of State,Apportionment,,United States,,\n", + "\n", + "3 ,delegation,population,Resident population,population abroad,,\n", + "\n", + "4 ,,,,,,\n", + "\n", + "5 United States ,435,\"1 249,022,783\",\"248,709,873\",\"922,819\",,\n", + "\n", + "6 ,,,,,,\n", + "\n", + "7 Alabama……………………………………..,7,\"4,062,608\",\"4,040,587\",\"22,021\",,\n", + "\n", + "8 Alaska……………………………………..,1,\"551,947\",\"550,043\",\"1,904\",,\n", + "\n", + "9 Arizona……………………………………..,6,\"3,677,985\",\"3,665,228\",\"12,757\",,\n", + "\n", + "10 Arkansas……………………………………..,4,\"2,362,239\",\"2,350,725\",\"11,514\",,\n", + "\n", + "11 California……………………………………..,52,\"29,839,250\",\"29,760,021\",\"79,229\",,\n", + "\n", + "12 Colorado……………………………………..,6,\"3,307,912\",\"3,294,394\",\"13,518\",,\n", + "\n", + "13 Connecticut……………………………………..,6,\"3,295,669\",\"3,287,116\",\"8,553\",,\n", + "\n", + "14 Delaware……………………………………..,1,\"668,696\",\"666,168\",\"2,528\",,\n", + "\n", + "15 District of Columbia……………………………………..,...,…,\"606,900\",\"3,009\",,\n", + "\n", + "16 Florida……………………………………..,23,\"13,003,362\",\"12,937,926\",\"65,436\",,\n", + "\n", + "17 Georgia……………………………………..,11,\"6,508,419\",\"6,478,216\",\"30,203\",,\n", + "\n", + "18 Hawaii……………………………………..,2,\"1,115,274\",\"1,108,229\",\"7,045\",,\n", + "\n", + "19 Idaho……………………………………..,2,\"1,011,986\",\"1,006,749\",\"5,237\",,\n", + "\n", + "20 Illinois……………………………………..,20,\"11,466,682\",\"11,430,602\",\"36,080\",,\n", + "\n", + "21 Indiana……………………………………..,10,\"5,564,228\",\"5,544,159\",\"20,069\",,\n", + "\n", + "22 Iowa……………………………………..,5,\"2,787,424\",\"2,776,755\",\"10,669\",,\n", + "\n", + "23 Kansas……………………………………..,4,\"2,485,600\",\"2,477,574\",\"8,026\",,\n", + "\n", + "24 Kentucky……………………………………..,6,\"3,698,969\",\"3,685,296\",\"13,673\",,\n", + "\n", + "25 Louisiana……………………………………..,7,\"4,238,216\",\"4,219,973\",\"18,243\",,\n", + "\n", + "26 Maine……………………………………..,2,\"1,233,223\",\"1,227,928\",\"5,295\",,\n", + "\n", + "27 Maryland……………………………………..,8,\"4,798,622\",\"4,781,468\",\"17,154\",,\n", + "\n", + "28 Massachusetts……………………………………..,10,\"6,029,051\",\"6,016,425\",\"12,626\",,\n", + "\n", + "29 Michigan……………………………………..,16,\"9,328,784\",\"9,295,297\",\"33,487\",,\n", + "\n", + "30 Minnesota……………………………………..,8,\"4,387,029\",\"4,375,099\",\"11,930\",,\n", + "\n", + "31 Mississippi……………………………………..,5,\"2,586,443\",\"2,573,216\",\"13,227\",,\n", + "\n", + "32 Missouri……………………………………..,9,\"5,137,804\",\"5,117,073\",\"20,731\",,\n", + "\n", + "33 Montana……………………………………..,1,\"803,655\",\"799,065\",\"4,590\",,\n", + "\n", + "34 Nebraska……………………………………..,3,\"1,584,617\",\"1,578,385\",\"6,232\",,\n", + "\n", + "35 Nevada……………………………………..,2,\"1,206,152\",\"1,201,833\",\"4,319\",,\n", + "\n", + "36 New Hampshire……………………………………..,2,\"1,113,915\",\"1,109,252\",\"4,663\",,\n", + "\n", + "37 New Jersey……………………………………..,13,\"7,748,634\",\"7,730,188\",\"18,446\",,\n", + "\n", + "38 New Mexico……………………………………..,3,\"1,521,779\",\"1,515,069\",\"6,710\",,\n", + "\n", + "39 New York……………………………………..,31,\"18,044,505\",\"17,990,455\",\"54,050\",,\n", + "\n", + "40 North Carolina……………………………………..,12,\"6,657,630\",\"6,628,637\",\"28,993\",,\n", + "\n", + "41 North Dakota……………………………………..,1,\"641,364\",\"638,800\",\"2,564\",,\n", + "\n", + "42 Ohio……………………………………..,19,\"10,887,325\",\"10,847,115\",\"40,210\",,\n", + "\n", + "43 Oklahoma……………………………………..,6,\"3,157,604\",\"3,145,585\",\"12,019\",,\n", + "\n", + "44 Oregon……………………………………..,5,\"2,853,733\",\"2,842,321\",\"11,412\",,\n", + "\n", + "45 Pennsylvania……………………………………..,21,\"11,924,710\",\"11,881,643\",\"43,067\",,\n", + "\n", + "46 Rhode Island……………………………………..,2,\"1,005,984\",\"1,003,464\",\"2,520\",,\n", + "\n", + "47 South Carolina……………………………………..,6,\"3,505,707\",\"3,486,703\",\"19,004\",,\n", + "\n", + "48 South Dakota……………………………………..,1,\"699,999\",\"696,004\",\"3,995\",,\n", + "\n", + "49 Tennessee……………………………………..,9,\"4,896,641\",\"4,877,185\",\"19,456\",,\n", + "\n", + "50 Texas……………………………………..,30,\"17,059,805\",\"16,986,510\",\"73,295\",,\n", + "\n", + "51 Utah……………………………………..,3,\"1,727,784\",\"1,722,850\",\"4,934\",,\n", + "\n", + "52 Vermont……………………………………..,1,\"564,964\",\"562,758\",\"2,206\",,\n", + "\n", + "53 Virginia……………………………………..,11,\"6,216,568\",\"6,187,358\",\"29,210\",,\n", + "\n", + "54 Washington……………………………………..,9,\"4,887,941\",\"4,866,692\",\"21,249\",,\n", + "\n", + "55 West Virginia……………………………………..,3,\"1,801,625\",\"1,793,477\",\"8,148\",,\n", + "\n", + "56 Wisconsin……………………………………..,9,\"4,906,745\",\"4,891,769\",\"14,976\",,\n", + "\n", + "57 Wyoming……………………………………..,1,\"455,975\",\"453,588\",\"2,387\",,\n", + "\n", + "58 ,,,,,,\n", + "\n", + "59 1 The apportionment population does not include the resident or the overseas population for the District of Columbia,,,,,,\n" + ] + } + ], + "source": [ + "### review the 1990 file\n", + "\n", + "with open('1990_apportionment_raw.csv', 'r') as f:\n", + " w = 0\n", + " for line in f.readlines():\n", + " print(w, line)\n", + " w +=1" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "### lordy, that is horrid. Try with csv reader\n", + "import csv" + ] + }, + { + "cell_type": "code", + "execution_count": 37, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "60" + ] + }, + "execution_count": 37, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "with open('1990_apportionment_raw.txt', newline='') as csvfile:\n", + " reader = csv.reader(csvfile, delimiter='\\t', quotechar='|')\n", + " #for row in reader:\n", + " # print(row)\n", + " f = [x for x in reader]\n", + " \n", + "len(f) " + ] + }, + { + "cell_type": "code", + "execution_count": 40, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "[['States ', 'Size of State', 'Apportionment', '', 'United States', '', ''],\n", + " ['',\n", + " 'delegation',\n", + " 'population',\n", + " 'Resident population',\n", + " 'population abroad',\n", + " '',\n", + " '']]" + ] + }, + "execution_count": 40, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "f[2:4]" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "'State'" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "(f[2][0].strip() + ' '+ f[3][0].strip()).strip()" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "'delegation'" + ] + }, + "execution_count": 31, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "f[3][1]" + ] + }, + { + "cell_type": "code", + "execution_count": 41, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "['States',\n", + " 'Size of State delegation',\n", + " 'Apportionment population',\n", + " 'Resident population',\n", + " 'United States population abroad',\n", + " '',\n", + " '']" + ] + }, + "execution_count": 41, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "header_names = [(f[2][x].strip() + ' '+ f[3][x].strip()).strip() for x in range(len(f[2]))]\n", + "header_names" + ] + }, + { + "cell_type": "code", + "execution_count": 47, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " at 0x114150ae8> some\u0000string. with\u0015 funny characters\n" + ] + } + ], + "source": [ + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 56, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "import re\n", + "fxn = lambda x: re.sub(r'[^\\x00-\\x7f]',r'',x).strip('.')" + ] + }, + { + "cell_type": "code", + "execution_count": 58, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "'Alabama'" + ] + }, + "execution_count": 58, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "fxn(f[7][0])" + ] + }, + { + "cell_type": "code", + "execution_count": 111, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "60" + ] + }, + "execution_count": 111, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import re\n", + "fxn = lambda x: re.sub(r'[^\\x00-\\x7f]',r'',x).strip('.').strip('\"').upper()\n", + "g = []\n", + "with open('1990_apportionment_raw.txt', newline='') as csvfile:\n", + " reader = csv.reader(csvfile, delimiter='\\t', quotechar='|')\n", + " for row in reader:\n", + " g.append([fxn(x) for x in row[:5]])\n", + " \n", + " \n", + "len(g) " + ] + }, + { + "cell_type": "code", + "execution_count": 109, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "'ALASKA'" + ] + }, + "execution_count": 109, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "fxn(f[8][0])" + ] + }, + { + "cell_type": "code", + "execution_count": 110, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "['ALASKA', '1', '551,947', '550,043', '1,904', '']" + ] + }, + "execution_count": 110, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "g[8]" + ] + }, + { + "cell_type": "code", + "execution_count": 112, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "header_names = [(g[2][x].strip() + ' '+ g[3][x].strip()).strip() for x in range(len(g[2]))]" + ] + }, + { + "cell_type": "code", + "execution_count": 113, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "['STATES',\n", + " 'SIZE OF STATE DELEGATION',\n", + " 'APPORTIONMENT POPULATION',\n", + " 'RESIDENT POPULATION',\n", + " 'UNITED STATES POPULATION ABROAD']" + ] + }, + "execution_count": 113, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "header_names" + ] + }, + { + "cell_type": "code", + "execution_count": 114, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "['ALABAMA', '7', '4,062,608', '4,040,587', '22,021']" + ] + }, + "execution_count": 114, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "g[7]" + ] + }, + { + "cell_type": "code", + "execution_count": 115, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "['WYOMING', '1', '455,975', '453,588', '2,387']" + ] + }, + "execution_count": 115, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "g[57]" + ] + }, + { + "cell_type": "code", + "execution_count": 242, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "g1 = g[7:58]" + ] + }, + { + "cell_type": "code", + "execution_count": 243, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "['WYOMING', '1', '455,975', '453,588', '2,387']" + ] + }, + "execution_count": 243, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "g1[-1]" + ] + }, + { + "cell_type": "code", + "execution_count": 244, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "ca1990 = pd.DataFrame(g1, columns=header_names) " + ] + }, + { + "cell_type": "code", + "execution_count": 245, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
STATESSIZE OF STATE DELEGATIONAPPORTIONMENT POPULATIONRESIDENT POPULATIONUNITED STATES POPULATION ABROAD
0ALABAMA74,062,6084,040,58722,021
1ALASKA1551,947550,0431,904
2ARIZONA63,677,9853,665,22812,757
3ARKANSAS42,362,2392,350,72511,514
4CALIFORNIA5229,839,25029,760,02179,229
\n", + "
" + ], + "text/plain": [ + " STATES SIZE OF STATE DELEGATION APPORTIONMENT POPULATION \\\n", + "0 ALABAMA 7 4,062,608 \n", + "1 ALASKA 1 551,947 \n", + "2 ARIZONA 6 3,677,985 \n", + "3 ARKANSAS 4 2,362,239 \n", + "4 CALIFORNIA 52 29,839,250 \n", + "\n", + " RESIDENT POPULATION UNITED STATES POPULATION ABROAD \n", + "0 4,040,587 22,021 \n", + "1 550,043 1,904 \n", + "2 3,665,228 12,757 \n", + "3 2,350,725 11,514 \n", + "4 29,760,021 79,229 " + ] + }, + "execution_count": 245, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "ca1990.head()" + ] + }, + { + "cell_type": "code", + "execution_count": 246, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "str" + ] + }, + "execution_count": 246, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "type(ca1990['SIZE OF STATE DELEGATION'][0])" + ] + }, + { + "cell_type": "code", + "execution_count": 129, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 247, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "for y in ca1990.columns[1:]:\n", + " ca1990[y] = ca1990[y].map(\n", + " lambda x: int(x.replace(',','')) if x != '' else 0)" + ] + }, + { + "cell_type": "code", + "execution_count": 248, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
STATESSIZE OF STATE DELEGATIONAPPORTIONMENT POPULATIONRESIDENT POPULATIONUNITED STATES POPULATION ABROAD
0ALABAMA74062608404058722021
1ALASKA15519475500431904
2ARIZONA63677985366522812757
3ARKANSAS42362239235072511514
4CALIFORNIA52298392502976002179229
5COLORADO63307912329439413518
6CONNECTICUT6329566932871168553
7DELAWARE16686966661682528
8DISTRICT OF COLUMBIA006069003009
9FLORIDA23130033621293792665436
10GEORGIA116508419647821630203
11HAWAII2111527411082297045
12IDAHO2101198610067495237
13ILLINOIS20114666821143060236080
14INDIANA105564228554415920069
\n", + "
" + ], + "text/plain": [ + " STATES SIZE OF STATE DELEGATION APPORTIONMENT POPULATION \\\n", + "0 ALABAMA 7 4062608 \n", + "1 ALASKA 1 551947 \n", + "2 ARIZONA 6 3677985 \n", + "3 ARKANSAS 4 2362239 \n", + "4 CALIFORNIA 52 29839250 \n", + "5 COLORADO 6 3307912 \n", + "6 CONNECTICUT 6 3295669 \n", + "7 DELAWARE 1 668696 \n", + "8 DISTRICT OF COLUMBIA 0 0 \n", + "9 FLORIDA 23 13003362 \n", + "10 GEORGIA 11 6508419 \n", + "11 HAWAII 2 1115274 \n", + "12 IDAHO 2 1011986 \n", + "13 ILLINOIS 20 11466682 \n", + "14 INDIANA 10 5564228 \n", + "\n", + " RESIDENT POPULATION UNITED STATES POPULATION ABROAD \n", + "0 4040587 22021 \n", + "1 550043 1904 \n", + "2 3665228 12757 \n", + "3 2350725 11514 \n", + "4 29760021 79229 \n", + "5 3294394 13518 \n", + "6 3287116 8553 \n", + "7 666168 2528 \n", + "8 606900 3009 \n", + "9 12937926 65436 \n", + "10 6478216 30203 \n", + "11 1108229 7045 \n", + "12 1006749 5237 \n", + "13 11430602 36080 \n", + "14 5544159 20069 " + ] + }, + "execution_count": 248, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "ca1990.head(15)" + ] + }, + { + "cell_type": "code", + "execution_count": 249, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "### Twenty-third Amendment gives DC 3 electoral votes \n", + "ca1990['TOTAL ELECTORAL VOTES'] = ca1990['SIZE OF STATE DELEGATION'].map(\n", + " lambda x: int(x)+2 if x != 0 else 3)" + ] + }, + { + "cell_type": "code", + "execution_count": 250, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
STATESSIZE OF STATE DELEGATIONAPPORTIONMENT POPULATIONRESIDENT POPULATIONUNITED STATES POPULATION ABROADTOTAL ELECTORAL VOTES
0ALABAMA740626084040587220219
1ALASKA155194755004319043
2ARIZONA636779853665228127578
3ARKANSAS423622392350725115146
4CALIFORNIA5229839250297600217922954
5COLORADO633079123294394135188
6CONNECTICUT63295669328711685538
7DELAWARE166869666616825283
8DISTRICT OF COLUMBIA0060690030093
9FLORIDA2313003362129379266543625
\n", + "
" + ], + "text/plain": [ + " STATES SIZE OF STATE DELEGATION APPORTIONMENT POPULATION \\\n", + "0 ALABAMA 7 4062608 \n", + "1 ALASKA 1 551947 \n", + "2 ARIZONA 6 3677985 \n", + "3 ARKANSAS 4 2362239 \n", + "4 CALIFORNIA 52 29839250 \n", + "5 COLORADO 6 3307912 \n", + "6 CONNECTICUT 6 3295669 \n", + "7 DELAWARE 1 668696 \n", + "8 DISTRICT OF COLUMBIA 0 0 \n", + "9 FLORIDA 23 13003362 \n", + "\n", + " RESIDENT POPULATION UNITED STATES POPULATION ABROAD TOTAL ELECTORAL VOTES \n", + "0 4040587 22021 9 \n", + "1 550043 1904 3 \n", + "2 3665228 12757 8 \n", + "3 2350725 11514 6 \n", + "4 29760021 79229 54 \n", + "5 3294394 13518 8 \n", + "6 3287116 8553 8 \n", + "7 666168 2528 3 \n", + "8 606900 3009 3 \n", + "9 12937926 65436 25 " + ] + }, + "execution_count": 250, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "ca1990.head(10)" + ] + }, + { + "cell_type": "code", + "execution_count": 251, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "ca1990['NUMBER OF CITIZENS PER ELECTORAL VOTE'] = ca1990['APPORTIONMENT POPULATION']/ca1990['TOTAL ELECTORAL VOTES']" + ] + }, + { + "cell_type": "code", + "execution_count": 252, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "ca1990['NUMBER OF CITIZENS PER ELECTORAL VOTE'] = ca1990['NUMBER OF CITIZENS PER ELECTORAL VOTE'].map(lambda x: int(x))" + ] + }, + { + "cell_type": "code", + "execution_count": 193, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 253, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
STATESSIZE OF STATE DELEGATIONAPPORTIONMENT POPULATIONRESIDENT POPULATIONUNITED STATES POPULATION ABROADTOTAL ELECTORAL VOTESNUMBER OF CITIZENS PER ELECTORAL VOTE
0ALABAMA740626084040587220219451400
1ALASKA155194755004319043183982
2ARIZONA636779853665228127578459748
3ARKANSAS423622392350725115146393706
4CALIFORNIA5229839250297600217922954552578
5COLORADO633079123294394135188413489
6CONNECTICUT63295669328711685538411958
7DELAWARE166869666616825283222898
8DISTRICT OF COLUMBIA00606900300930
9FLORIDA2313003362129379266543625520134
\n", + "
" + ], + "text/plain": [ + " STATES SIZE OF STATE DELEGATION APPORTIONMENT POPULATION \\\n", + "0 ALABAMA 7 4062608 \n", + "1 ALASKA 1 551947 \n", + "2 ARIZONA 6 3677985 \n", + "3 ARKANSAS 4 2362239 \n", + "4 CALIFORNIA 52 29839250 \n", + "5 COLORADO 6 3307912 \n", + "6 CONNECTICUT 6 3295669 \n", + "7 DELAWARE 1 668696 \n", + "8 DISTRICT OF COLUMBIA 0 0 \n", + "9 FLORIDA 23 13003362 \n", + "\n", + " RESIDENT POPULATION UNITED STATES POPULATION ABROAD \\\n", + "0 4040587 22021 \n", + "1 550043 1904 \n", + "2 3665228 12757 \n", + "3 2350725 11514 \n", + "4 29760021 79229 \n", + "5 3294394 13518 \n", + "6 3287116 8553 \n", + "7 666168 2528 \n", + "8 606900 3009 \n", + "9 12937926 65436 \n", + "\n", + " TOTAL ELECTORAL VOTES NUMBER OF CITIZENS PER ELECTORAL VOTE \n", + "0 9 451400 \n", + "1 3 183982 \n", + "2 8 459748 \n", + "3 6 393706 \n", + "4 54 552578 \n", + "5 8 413489 \n", + "6 8 411958 \n", + "7 3 222898 \n", + "8 3 0 \n", + "9 25 520134 " + ] + }, + "execution_count": 253, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "ca1990.head(10)" + ] + }, + { + "cell_type": "code", + "execution_count": 254, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/nicholeh/anaconda/lib/python3.5/site-packages/pandas/core/indexing.py:141: SettingWithCopyWarning: \n", + "A value is trying to be set on a copy of a slice from a DataFrame\n", + "\n", + "See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy\n", + " self._setitem_with_indexer(indexer, value)\n" + ] + } + ], + "source": [ + "### fix DC \n", + "dc_res = ca1990['RESIDENT POPULATION'].ix[8] + ca1990['UNITED STATES POPULATION ABROAD'].ix[8]\n", + "ca1990['NUMBER OF CITIZENS PER ELECTORAL VOTE'].ix[8] = int(dc_res/ca1990['TOTAL ELECTORAL VOTES'].ix[8])" + ] + }, + { + "cell_type": "code", + "execution_count": 255, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
STATESSIZE OF STATE DELEGATIONAPPORTIONMENT POPULATIONRESIDENT POPULATIONUNITED STATES POPULATION ABROADTOTAL ELECTORAL VOTESNUMBER OF CITIZENS PER ELECTORAL VOTE
0ALABAMA740626084040587220219451400
1ALASKA155194755004319043183982
2ARIZONA636779853665228127578459748
3ARKANSAS423622392350725115146393706
4CALIFORNIA5229839250297600217922954552578
5COLORADO633079123294394135188413489
6CONNECTICUT63295669328711685538411958
7DELAWARE166869666616825283222898
8DISTRICT OF COLUMBIA0060690030093203303
9FLORIDA2313003362129379266543625520134
\n", + "
" + ], + "text/plain": [ + " STATES SIZE OF STATE DELEGATION APPORTIONMENT POPULATION \\\n", + "0 ALABAMA 7 4062608 \n", + "1 ALASKA 1 551947 \n", + "2 ARIZONA 6 3677985 \n", + "3 ARKANSAS 4 2362239 \n", + "4 CALIFORNIA 52 29839250 \n", + "5 COLORADO 6 3307912 \n", + "6 CONNECTICUT 6 3295669 \n", + "7 DELAWARE 1 668696 \n", + "8 DISTRICT OF COLUMBIA 0 0 \n", + "9 FLORIDA 23 13003362 \n", + "\n", + " RESIDENT POPULATION UNITED STATES POPULATION ABROAD \\\n", + "0 4040587 22021 \n", + "1 550043 1904 \n", + "2 3665228 12757 \n", + "3 2350725 11514 \n", + "4 29760021 79229 \n", + "5 3294394 13518 \n", + "6 3287116 8553 \n", + "7 666168 2528 \n", + "8 606900 3009 \n", + "9 12937926 65436 \n", + "\n", + " TOTAL ELECTORAL VOTES NUMBER OF CITIZENS PER ELECTORAL VOTE \n", + "0 9 451400 \n", + "1 3 183982 \n", + "2 8 459748 \n", + "3 6 393706 \n", + "4 54 552578 \n", + "5 8 413489 \n", + "6 8 411958 \n", + "7 3 222898 \n", + "8 3 203303 \n", + "9 25 520134 " + ] + }, + "execution_count": 255, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "ca1990.head(10)" + ] + }, + { + "cell_type": "code", + "execution_count": 256, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "total_res = dc[3] + dc[4]" + ] + }, + { + "cell_type": "code", + "execution_count": 257, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "0" + ] + }, + "execution_count": 257, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "dc[2]" + ] + }, + { + "cell_type": "code", + "execution_count": 258, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "ca1990.to_csv('1990_apportionment_cleaned.tsv', sep = '\\t', index=False)" + ] + }, + { + "cell_type": "code", + "execution_count": 241, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 241, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "# 2000 data\n", + "import csv\n", + "with open('2000_apportionment_raw.txt', newline='') as csvfile:\n", + " reader = csv.reader(csvfile, delimiter='\\t', quotechar='|')\n", + " #for row in reader:\n", + " # print(row)\n", + " f = [x for x in reader]" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "[['\"Table 1. Apportionment Population and Number of Representatives, by State: Census 2000\"',\n", + " '',\n", + " '',\n", + " '',\n", + " '',\n", + " ''],\n", + " [' ', '', '', '', '', ''],\n", + " [' State',\n", + " 'Apportionment Population',\n", + " 'Number of Apportioned Representatives Based on Census 2000',\n", + " 'Change From 1990 Census Apportionment',\n", + " '',\n", + " ''],\n", + " ['', '', '', '', '', ''],\n", + " ['', '', '', '', '', '']]" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "f[:5]" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "[' Alabama', '\"4,461,130\"', '7', '0', '', '']" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "f[6]" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "['State',\n", + " 'Apportionment Population',\n", + " 'Number of Apportioned Representatives Based on Census 2000',\n", + " 'Change From 1990 Census Apportionment',\n", + " '',\n", + " '']" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "header_names = [(f[2][x].strip() + ' '+ f[3][x].strip()).strip() for x in range(len(f[2]))]\n", + "header_names" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "68" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import re\n", + "fxn = lambda x: re.sub(r'[^\\x00-\\x7f]',r'',x).strip('.').strip('\"').upper()\n", + "g = []\n", + "with open('2000_apportionment_raw.txt', newline='') as csvfile:\n", + " reader = csv.reader(csvfile, delimiter='\\t', quotechar='|')\n", + " for row in reader:\n", + " g.append([fxn(x) for x in row[:4]])\n", + " \n", + " \n", + "len(g)" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "[['TABLE 1. APPORTIONMENT POPULATION AND NUMBER OF REPRESENTATIVES, BY STATE: CENSUS 2000',\n", + " '',\n", + " '',\n", + " ''],\n", + " [' ', '', '', ''],\n", + " [' STATE',\n", + " 'APPORTIONMENT POPULATION',\n", + " 'NUMBER OF APPORTIONED REPRESENTATIVES BASED ON CENSUS 2000',\n", + " 'CHANGE FROM 1990 CENSUS APPORTIONMENT'],\n", + " ['', '', '', ''],\n", + " ['', '', '', ''],\n", + " ['', '', '', ''],\n", + " [' ALABAMA', '4,461,130', '7', '0'],\n", + " [' ALASKA', '628,933', '1', '0'],\n", + " [' ARIZONA', '5,140,683', '8', '+2'],\n", + " [' ARKANSAS', '2,679,733', '4', '0']]" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "g[:10\n", + "]" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "header_names = [(g[2][x].strip() + ' '+ g[3][x].strip()).strip() for x in range(len(g[2]))]" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "['STATE',\n", + " 'APPORTIONMENT POPULATION',\n", + " 'NUMBER OF APPORTIONED REPRESENTATIVES BASED ON CENSUS 2000',\n", + " 'CHANGE FROM 1990 CENSUS APPORTIONMENT']" + ] + }, + "execution_count": 16, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "header_names" + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "ca2000 = pd.DataFrame(g[6:56], columns=header_names) " + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
STATEAPPORTIONMENT POPULATIONNUMBER OF APPORTIONED REPRESENTATIVES BASED ON CENSUS 2000CHANGE FROM 1990 CENSUS APPORTIONMENT
45VIRGINIA7,100,702110
46WASHINGTON5,908,68490
47WEST VIRGINIA1,813,07730
48WISCONSIN5,371,2108-1
49WYOMING495,30410
\n", + "
" + ], + "text/plain": [ + " STATE APPORTIONMENT POPULATION \\\n", + "45 VIRGINIA 7,100,702 \n", + "46 WASHINGTON 5,908,684 \n", + "47 WEST VIRGINIA 1,813,077 \n", + "48 WISCONSIN 5,371,210 \n", + "49 WYOMING 495,304 \n", + "\n", + " NUMBER OF APPORTIONED REPRESENTATIVES BASED ON CENSUS 2000 \\\n", + "45 11 \n", + "46 9 \n", + "47 3 \n", + "48 8 \n", + "49 1 \n", + "\n", + " CHANGE FROM 1990 CENSUS APPORTIONMENT \n", + "45 0 \n", + "46 0 \n", + "47 0 \n", + "48 -1 \n", + "49 0 " + ] + }, + "execution_count": 27, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "ca2000.tail()" + ] + }, + { + "cell_type": "code", + "execution_count": 28, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
STATEAPPORTIONMENT POPULATIONNUMBER OF APPORTIONED REPRESENTATIVES BASED ON CENSUS 2000CHANGE FROM 1990 CENSUS APPORTIONMENT
0ALABAMA4,461,13070
1ALASKA628,93310
2ARIZONA5,140,6838+2
3ARKANSAS2,679,73340
4CALIFORNIA33,930,79853+1
5COLORADO4,311,8827+1
6CONNECTICUT3,409,5355-1
7DELAWARE785,06810
8FLORIDA16,028,89025+2
9GEORGIA8,206,97513+2
\n", + "
" + ], + "text/plain": [ + " STATE APPORTIONMENT POPULATION \\\n", + "0 ALABAMA 4,461,130 \n", + "1 ALASKA 628,933 \n", + "2 ARIZONA 5,140,683 \n", + "3 ARKANSAS 2,679,733 \n", + "4 CALIFORNIA 33,930,798 \n", + "5 COLORADO 4,311,882 \n", + "6 CONNECTICUT 3,409,535 \n", + "7 DELAWARE 785,068 \n", + "8 FLORIDA 16,028,890 \n", + "9 GEORGIA 8,206,975 \n", + "\n", + " NUMBER OF APPORTIONED REPRESENTATIVES BASED ON CENSUS 2000 \\\n", + "0 7 \n", + "1 1 \n", + "2 8 \n", + "3 4 \n", + "4 53 \n", + "5 7 \n", + "6 5 \n", + "7 1 \n", + "8 25 \n", + "9 13 \n", + "\n", + " CHANGE FROM 1990 CENSUS APPORTIONMENT \n", + "0 0 \n", + "1 0 \n", + "2 +2 \n", + "3 0 \n", + "4 +1 \n", + "5 +1 \n", + "6 -1 \n", + "7 0 \n", + "8 +2 \n", + "9 +2 " + ] + }, + "execution_count": 28, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "ca2000.head(10)" + ] + }, + { + "cell_type": "code", + "execution_count": 29, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "str" + ] + }, + "execution_count": 29, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "type(ca2000['NUMBER OF APPORTIONED REPRESENTATIVES BASED ON CENSUS 2000'][5])" + ] + }, + { + "cell_type": "code", + "execution_count": 30, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "ca2000['NUMBER OF APPORTIONED REPRESENTATIVES BASED ON CENSUS 2000'] = ca2000['NUMBER OF APPORTIONED REPRESENTATIVES BASED ON CENSUS 2000'].map(lambda x: int(x))" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "numpy.int64" + ] + }, + "execution_count": 31, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "type(ca2000['NUMBER OF APPORTIONED REPRESENTATIVES BASED ON CENSUS 2000'][5])" + ] + }, + { + "cell_type": "code", + "execution_count": 32, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
STATEAPPORTIONMENT POPULATIONNUMBER OF APPORTIONED REPRESENTATIVES BASED ON CENSUS 2000CHANGE FROM 1990 CENSUS APPORTIONMENT
0ALABAMA4,461,13070
1ALASKA628,93310
2ARIZONA5,140,6838+2
3ARKANSAS2,679,73340
4CALIFORNIA33,930,79853+1
5COLORADO4,311,8827+1
6CONNECTICUT3,409,5355-1
7DELAWARE785,06810
8FLORIDA16,028,89025+2
9GEORGIA8,206,97513+2
\n", + "
" + ], + "text/plain": [ + " STATE APPORTIONMENT POPULATION \\\n", + "0 ALABAMA 4,461,130 \n", + "1 ALASKA 628,933 \n", + "2 ARIZONA 5,140,683 \n", + "3 ARKANSAS 2,679,733 \n", + "4 CALIFORNIA 33,930,798 \n", + "5 COLORADO 4,311,882 \n", + "6 CONNECTICUT 3,409,535 \n", + "7 DELAWARE 785,068 \n", + "8 FLORIDA 16,028,890 \n", + "9 GEORGIA 8,206,975 \n", + "\n", + " NUMBER OF APPORTIONED REPRESENTATIVES BASED ON CENSUS 2000 \\\n", + "0 7 \n", + "1 1 \n", + "2 8 \n", + "3 4 \n", + "4 53 \n", + "5 7 \n", + "6 5 \n", + "7 1 \n", + "8 25 \n", + "9 13 \n", + "\n", + " CHANGE FROM 1990 CENSUS APPORTIONMENT \n", + "0 0 \n", + "1 0 \n", + "2 +2 \n", + "3 0 \n", + "4 +1 \n", + "5 +1 \n", + "6 -1 \n", + "7 0 \n", + "8 +2 \n", + "9 +2 " + ] + }, + "execution_count": 32, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "ca2000.head(10)" + ] + }, + { + "cell_type": "code", + "execution_count": 33, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "ca2000['APPORTIONMENT POPULATION'] = ca2000['APPORTIONMENT POPULATION'].map(\n", + " lambda x: int(x.replace(',','')) if x != '' else 0)" + ] + }, + { + "cell_type": "code", + "execution_count": 34, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
STATEAPPORTIONMENT POPULATIONNUMBER OF APPORTIONED REPRESENTATIVES BASED ON CENSUS 2000CHANGE FROM 1990 CENSUS APPORTIONMENT
0ALABAMA446113070
1ALASKA62893310
2ARIZONA51406838+2
3ARKANSAS267973340
4CALIFORNIA3393079853+1
5COLORADO43118827+1
6CONNECTICUT34095355-1
7DELAWARE78506810
8FLORIDA1602889025+2
9GEORGIA820697513+2
\n", + "
" + ], + "text/plain": [ + " STATE APPORTIONMENT POPULATION \\\n", + "0 ALABAMA 4461130 \n", + "1 ALASKA 628933 \n", + "2 ARIZONA 5140683 \n", + "3 ARKANSAS 2679733 \n", + "4 CALIFORNIA 33930798 \n", + "5 COLORADO 4311882 \n", + "6 CONNECTICUT 3409535 \n", + "7 DELAWARE 785068 \n", + "8 FLORIDA 16028890 \n", + "9 GEORGIA 8206975 \n", + "\n", + " NUMBER OF APPORTIONED REPRESENTATIVES BASED ON CENSUS 2000 \\\n", + "0 7 \n", + "1 1 \n", + "2 8 \n", + "3 4 \n", + "4 53 \n", + "5 7 \n", + "6 5 \n", + "7 1 \n", + "8 25 \n", + "9 13 \n", + "\n", + " CHANGE FROM 1990 CENSUS APPORTIONMENT \n", + "0 0 \n", + "1 0 \n", + "2 +2 \n", + "3 0 \n", + "4 +1 \n", + "5 +1 \n", + "6 -1 \n", + "7 0 \n", + "8 +2 \n", + "9 +2 " + ] + }, + "execution_count": 34, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "ca2000.head(10)" + ] + }, + { + "cell_type": "code", + "execution_count": 35, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "ca2000['TOTAL ELECTORAL VOTES'] = ca2000['NUMBER OF APPORTIONED REPRESENTATIVES BASED ON CENSUS 2000'] + 2" + ] + }, + { + "cell_type": "code", + "execution_count": 36, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
STATEAPPORTIONMENT POPULATIONNUMBER OF APPORTIONED REPRESENTATIVES BASED ON CENSUS 2000CHANGE FROM 1990 CENSUS APPORTIONMENTTOTAL ELECTORAL VOTES
0ALABAMA4461130709
1ALASKA628933103
2ARIZONA51406838+210
3ARKANSAS2679733406
4CALIFORNIA3393079853+155
5COLORADO43118827+19
6CONNECTICUT34095355-17
7DELAWARE785068103
8FLORIDA1602889025+227
9GEORGIA820697513+215
\n", + "
" + ], + "text/plain": [ + " STATE APPORTIONMENT POPULATION \\\n", + "0 ALABAMA 4461130 \n", + "1 ALASKA 628933 \n", + "2 ARIZONA 5140683 \n", + "3 ARKANSAS 2679733 \n", + "4 CALIFORNIA 33930798 \n", + "5 COLORADO 4311882 \n", + "6 CONNECTICUT 3409535 \n", + "7 DELAWARE 785068 \n", + "8 FLORIDA 16028890 \n", + "9 GEORGIA 8206975 \n", + "\n", + " NUMBER OF APPORTIONED REPRESENTATIVES BASED ON CENSUS 2000 \\\n", + "0 7 \n", + "1 1 \n", + "2 8 \n", + "3 4 \n", + "4 53 \n", + "5 7 \n", + "6 5 \n", + "7 1 \n", + "8 25 \n", + "9 13 \n", + "\n", + " CHANGE FROM 1990 CENSUS APPORTIONMENT TOTAL ELECTORAL VOTES \n", + "0 0 9 \n", + "1 0 3 \n", + "2 +2 10 \n", + "3 0 6 \n", + "4 +1 55 \n", + "5 +1 9 \n", + "6 -1 7 \n", + "7 0 3 \n", + "8 +2 27 \n", + "9 +2 15 " + ] + }, + "execution_count": 36, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "ca2000.head(10)" + ] + }, + { + "cell_type": "code", + "execution_count": 42, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "ca2000['NUMBER OF CITIZENS PER ELECTORAL VOTE'] = ca2000['APPORTIONMENT POPULATION']/ca2000['TOTAL ELECTORAL VOTES']" + ] + }, + { + "cell_type": "code", + "execution_count": 44, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "ca2000['NUMBER OF CITIZENS PER ELECTORAL VOTE'] = ca2000['NUMBER OF CITIZENS PER ELECTORAL VOTE'].map(lambda x: int(x))" + ] + }, + { + "cell_type": "code", + "execution_count": 45, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
STATEAPPORTIONMENT POPULATIONNUMBER OF APPORTIONED REPRESENTATIVES BASED ON CENSUS 2000CHANGE FROM 1990 CENSUS APPORTIONMENTTOTAL ELECTORAL VOTESNUMBER OF CITIZENS PER ELECTORAL VOTE
0ALABAMA4461130709495681
1ALASKA628933103209644
2ARIZONA51406838+210514068
3ARKANSAS2679733406446622
4CALIFORNIA3393079853+155616923
5COLORADO43118827+19479098
6CONNECTICUT34095355-17487076
7DELAWARE785068103261689
8FLORIDA1602889025+227593662
9GEORGIA820697513+215547131
\n", + "
" + ], + "text/plain": [ + " STATE APPORTIONMENT POPULATION \\\n", + "0 ALABAMA 4461130 \n", + "1 ALASKA 628933 \n", + "2 ARIZONA 5140683 \n", + "3 ARKANSAS 2679733 \n", + "4 CALIFORNIA 33930798 \n", + "5 COLORADO 4311882 \n", + "6 CONNECTICUT 3409535 \n", + "7 DELAWARE 785068 \n", + "8 FLORIDA 16028890 \n", + "9 GEORGIA 8206975 \n", + "\n", + " NUMBER OF APPORTIONED REPRESENTATIVES BASED ON CENSUS 2000 \\\n", + "0 7 \n", + "1 1 \n", + "2 8 \n", + "3 4 \n", + "4 53 \n", + "5 7 \n", + "6 5 \n", + "7 1 \n", + "8 25 \n", + "9 13 \n", + "\n", + " CHANGE FROM 1990 CENSUS APPORTIONMENT TOTAL ELECTORAL VOTES \\\n", + "0 0 9 \n", + "1 0 3 \n", + "2 +2 10 \n", + "3 0 6 \n", + "4 +1 55 \n", + "5 +1 9 \n", + "6 -1 7 \n", + "7 0 3 \n", + "8 +2 27 \n", + "9 +2 15 \n", + "\n", + " NUMBER OF CITIZENS PER ELECTORAL VOTE \n", + "0 495681 \n", + "1 209644 \n", + "2 514068 \n", + "3 446622 \n", + "4 616923 \n", + "5 479098 \n", + "6 487076 \n", + "7 261689 \n", + "8 593662 \n", + "9 547131 " + ] + }, + "execution_count": 45, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "ca2000.head(10)" + ] + }, + { + "cell_type": "code", + "execution_count": 46, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "ca2000.to_csv('2000_apportionment_cleaned.tsv', sep = '\\t', index=False)" + ] + }, + { + "cell_type": "code", + "execution_count": 47, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "c2_cleaned = pd.read_csv('2000_apportionment_cleaned.tsv', sep = '\\t')" + ] + }, + { + "cell_type": "code", + "execution_count": 49, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
STATEAPPORTIONMENT POPULATIONNUMBER OF APPORTIONED REPRESENTATIVES BASED ON CENSUS 2000CHANGE FROM 1990 CENSUS APPORTIONMENTTOTAL ELECTORAL VOTESNUMBER OF CITIZENS PER ELECTORAL VOTE
0ALABAMA4461130709495681
1ALASKA628933103209644
2ARIZONA51406838210514068
3ARKANSAS2679733406446622
4CALIFORNIA3393079853155616923
5COLORADO4311882719479098
6CONNECTICUT34095355-17487076
7DELAWARE785068103261689
8FLORIDA1602889025227593662
9GEORGIA820697513215547131
\n", + "
" + ], + "text/plain": [ + " STATE APPORTIONMENT POPULATION \\\n", + "0 ALABAMA 4461130 \n", + "1 ALASKA 628933 \n", + "2 ARIZONA 5140683 \n", + "3 ARKANSAS 2679733 \n", + "4 CALIFORNIA 33930798 \n", + "5 COLORADO 4311882 \n", + "6 CONNECTICUT 3409535 \n", + "7 DELAWARE 785068 \n", + "8 FLORIDA 16028890 \n", + "9 GEORGIA 8206975 \n", + "\n", + " NUMBER OF APPORTIONED REPRESENTATIVES BASED ON CENSUS 2000 \\\n", + "0 7 \n", + "1 1 \n", + "2 8 \n", + "3 4 \n", + "4 53 \n", + "5 7 \n", + "6 5 \n", + "7 1 \n", + "8 25 \n", + "9 13 \n", + "\n", + " CHANGE FROM 1990 CENSUS APPORTIONMENT TOTAL ELECTORAL VOTES \\\n", + "0 0 9 \n", + "1 0 3 \n", + "2 2 10 \n", + "3 0 6 \n", + "4 1 55 \n", + "5 1 9 \n", + "6 -1 7 \n", + "7 0 3 \n", + "8 2 27 \n", + "9 2 15 \n", + "\n", + " NUMBER OF CITIZENS PER ELECTORAL VOTE \n", + "0 495681 \n", + "1 209644 \n", + "2 514068 \n", + "3 446622 \n", + "4 616923 \n", + "5 479098 \n", + "6 487076 \n", + "7 261689 \n", + "8 593662 \n", + "9 547131 " + ] + }, + "execution_count": 49, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "c2_cleaned.head(10)" + ] + }, + { + "cell_type": "code", + "execution_count": 77, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "67" + ] + }, + "execution_count": 77, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import re\n", + "fxn = lambda x: re.sub(r'[^\\x00-\\x7f]',r'',x).strip('.').strip('\"').upper()\n", + "g = []\n", + "with open('2010_apportionment_raw.txt', newline='') as csvfile:\n", + " reader = csv.reader(csvfile, delimiter='\\t', quotechar='|')\n", + " for row in reader:\n", + " g.append([fxn(x) for x in row[:6]])\n", + " \n", + " \n", + "len(g)" + ] + }, + { + "cell_type": "code", + "execution_count": 78, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "[['U.S. DEPARTMENT OF COMMERCE', '', '', '', '', ''],\n", + " ['U.S. CENSUS BUREAU', '', '', '', '', ''],\n", + " ['', '', '', '', '', ''],\n", + " ['TABLE 1. APPORTIONMENT POPULATION AND NUMBER OF REPRESENTATIVES, BY STATE: 2010 CENSUS',\n", + " '',\n", + " '',\n", + " '',\n", + " '',\n", + " ''],\n", + " ['', '', '', '', '', ''],\n", + " ['', '', '', 'NUMBER OF APPORTIONED', '', ''],\n", + " ['', 'APPORTIONMENT', '', 'REPRESENTATIVES', '', 'CHANGE IN SEATS'],\n", + " ['', 'POPULATION', '', 'BASED ON', '', 'FROM CENSUS 2000'],\n", + " ['STATE', '(APRIL 1, 2010)', '', '2010 CENSUS', '', 'APPORTIONMENT'],\n", + " ['', '', '', '', '', '']]" + ] + }, + "execution_count": 78, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "g[:10]" + ] + }, + { + "cell_type": "code", + "execution_count": 79, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "header_names = [(g[5][x] + ' '+ g[6][x].strip() + \n", + " ' '+ g[7][x].strip() + ' ' + g[8][x].strip()).strip() for x in range(len(g[5]))]\n" + ] + }, + { + "cell_type": "code", + "execution_count": 80, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "['STATE',\n", + " 'APPORTIONMENT POPULATION (APRIL 1, 2010)',\n", + " '',\n", + " 'NUMBER OF APPORTIONED REPRESENTATIVES BASED ON 2010 CENSUS',\n", + " '',\n", + " 'CHANGE IN SEATS FROM CENSUS 2000 APPORTIONMENT']" + ] + }, + "execution_count": 80, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "header_names" + ] + }, + { + "cell_type": "code", + "execution_count": 82, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "['ALABAMA', '4,802,982', '', '7', '', '0']" + ] + }, + "execution_count": 82, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "g[11]" + ] + }, + { + "cell_type": "code", + "execution_count": 84, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "ca2010 = pd.DataFrame(g[11:11+50], columns=header_names) " + ] + }, + { + "cell_type": "code", + "execution_count": 87, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
STATEAPPORTIONMENT POPULATION (APRIL 1, 2010)NUMBER OF APPORTIONED REPRESENTATIVES BASED ON 2010 CENSUSCHANGE IN SEATS FROM CENSUS 2000 APPORTIONMENT
40SOUTH DAKOTA819,76110
41TENNESSEE6,375,43190
42TEXAS25,268,41836+4
43UTAH2,770,7654+1
44VERMONT630,33710
45VIRGINIA8,037,736110
46WASHINGTON6,753,36910+1
47WEST VIRGINIA1,859,81530
48WISCONSIN5,698,23080
49WYOMING568,30010
\n", + "
" + ], + "text/plain": [ + " STATE APPORTIONMENT POPULATION (APRIL 1, 2010) \\\n", + "40 SOUTH DAKOTA 819,761 \n", + "41 TENNESSEE 6,375,431 \n", + "42 TEXAS 25,268,418 \n", + "43 UTAH 2,770,765 \n", + "44 VERMONT 630,337 \n", + "45 VIRGINIA 8,037,736 \n", + "46 WASHINGTON 6,753,369 \n", + "47 WEST VIRGINIA 1,859,815 \n", + "48 WISCONSIN 5,698,230 \n", + "49 WYOMING 568,300 \n", + "\n", + " NUMBER OF APPORTIONED REPRESENTATIVES BASED ON 2010 CENSUS \\\n", + "40 1 \n", + "41 9 \n", + "42 36 \n", + "43 4 \n", + "44 1 \n", + "45 11 \n", + "46 10 \n", + "47 3 \n", + "48 8 \n", + "49 1 \n", + "\n", + " CHANGE IN SEATS FROM CENSUS 2000 APPORTIONMENT \n", + "40 0 \n", + "41 0 \n", + "42 +4 \n", + "43 +1 \n", + "44 0 \n", + "45 0 \n", + "46 +1 \n", + "47 0 \n", + "48 0 \n", + "49 0 " + ] + }, + "execution_count": 87, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "ca2010.tail(10)" + ] + }, + { + "cell_type": "code", + "execution_count": 88, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "ca2010 = ca2010[['STATE', 'APPORTIONMENT POPULATION (APRIL 1, 2010)',\n", + " 'NUMBER OF APPORTIONED REPRESENTATIVES BASED ON 2010 CENSUS', \n", + " 'CHANGE IN SEATS FROM CENSUS 2000 APPORTIONMENT']]" + ] + }, + { + "cell_type": "code", + "execution_count": 89, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
STATEAPPORTIONMENT POPULATION (APRIL 1, 2010)NUMBER OF APPORTIONED REPRESENTATIVES BASED ON 2010 CENSUSCHANGE IN SEATS FROM CENSUS 2000 APPORTIONMENT
0ALABAMA4,802,98270
1ALASKA721,52310
2ARIZONA6,412,7009+1
3ARKANSAS2,926,22940
4CALIFORNIA37,341,989530
5COLORADO5,044,93070
6CONNECTICUT3,581,62850
7DELAWARE900,87710
8FLORIDA18,900,77327+2
9GEORGIA9,727,56614+1
10HAWAII1,366,86220
11IDAHO1,573,49920
12ILLINOIS12,864,38018-1
13INDIANA6,501,58290
14IOWA3,053,7874-1
15KANSAS2,863,81340
16KENTUCKY4,350,60660
17LOUISIANA4,553,9626-1
18MAINE1,333,07420
19MARYLAND5,789,92980
20MASSACHUSETTS6,559,6449-1
21MICHIGAN9,911,62614-1
22MINNESOTA5,314,87980
23MISSISSIPPI2,978,24040
24MISSOURI6,011,4788-1
25MONTANA994,41610
26NEBRASKA1,831,82530
27NEVADA2,709,4324+1
28NEW HAMPSHIRE1,321,44520
29NEW JERSEY8,807,50112-1
30NEW MEXICO2,067,27330
31NEW YORK19,421,05527-2
32NORTH CAROLINA9,565,781130
33NORTH DAKOTA675,90510
34OHIO11,568,49516-2
35OKLAHOMA3,764,88250
36OREGON3,848,60650
37PENNSYLVANIA12,734,90518-1
38RHODE ISLAND1,055,24720
39SOUTH CAROLINA4,645,9757+1
40SOUTH DAKOTA819,76110
41TENNESSEE6,375,43190
42TEXAS25,268,41836+4
43UTAH2,770,7654+1
44VERMONT630,33710
45VIRGINIA8,037,736110
46WASHINGTON6,753,36910+1
47WEST VIRGINIA1,859,81530
48WISCONSIN5,698,23080
49WYOMING568,30010
\n", + "
" + ], + "text/plain": [ + " STATE APPORTIONMENT POPULATION (APRIL 1, 2010) \\\n", + "0 ALABAMA 4,802,982 \n", + "1 ALASKA 721,523 \n", + "2 ARIZONA 6,412,700 \n", + "3 ARKANSAS 2,926,229 \n", + "4 CALIFORNIA 37,341,989 \n", + "5 COLORADO 5,044,930 \n", + "6 CONNECTICUT 3,581,628 \n", + "7 DELAWARE 900,877 \n", + "8 FLORIDA 18,900,773 \n", + "9 GEORGIA 9,727,566 \n", + "10 HAWAII 1,366,862 \n", + "11 IDAHO 1,573,499 \n", + "12 ILLINOIS 12,864,380 \n", + "13 INDIANA 6,501,582 \n", + "14 IOWA 3,053,787 \n", + "15 KANSAS 2,863,813 \n", + "16 KENTUCKY 4,350,606 \n", + "17 LOUISIANA 4,553,962 \n", + "18 MAINE 1,333,074 \n", + "19 MARYLAND 5,789,929 \n", + "20 MASSACHUSETTS 6,559,644 \n", + "21 MICHIGAN 9,911,626 \n", + "22 MINNESOTA 5,314,879 \n", + "23 MISSISSIPPI 2,978,240 \n", + "24 MISSOURI 6,011,478 \n", + "25 MONTANA 994,416 \n", + "26 NEBRASKA 1,831,825 \n", + "27 NEVADA 2,709,432 \n", + "28 NEW HAMPSHIRE 1,321,445 \n", + "29 NEW JERSEY 8,807,501 \n", + "30 NEW MEXICO 2,067,273 \n", + "31 NEW YORK 19,421,055 \n", + "32 NORTH CAROLINA 9,565,781 \n", + "33 NORTH DAKOTA 675,905 \n", + "34 OHIO 11,568,495 \n", + "35 OKLAHOMA 3,764,882 \n", + "36 OREGON 3,848,606 \n", + "37 PENNSYLVANIA 12,734,905 \n", + "38 RHODE ISLAND 1,055,247 \n", + "39 SOUTH CAROLINA 4,645,975 \n", + "40 SOUTH DAKOTA 819,761 \n", + "41 TENNESSEE 6,375,431 \n", + "42 TEXAS 25,268,418 \n", + "43 UTAH 2,770,765 \n", + "44 VERMONT 630,337 \n", + "45 VIRGINIA 8,037,736 \n", + "46 WASHINGTON 6,753,369 \n", + "47 WEST VIRGINIA 1,859,815 \n", + "48 WISCONSIN 5,698,230 \n", + "49 WYOMING 568,300 \n", + "\n", + " NUMBER OF APPORTIONED REPRESENTATIVES BASED ON 2010 CENSUS \\\n", + "0 7 \n", + "1 1 \n", + "2 9 \n", + "3 4 \n", + "4 53 \n", + "5 7 \n", + "6 5 \n", + "7 1 \n", + "8 27 \n", + "9 14 \n", + "10 2 \n", + "11 2 \n", + "12 18 \n", + "13 9 \n", + "14 4 \n", + "15 4 \n", + "16 6 \n", + "17 6 \n", + "18 2 \n", + "19 8 \n", + "20 9 \n", + "21 14 \n", + "22 8 \n", + "23 4 \n", + "24 8 \n", + "25 1 \n", + "26 3 \n", + "27 4 \n", + "28 2 \n", + "29 12 \n", + "30 3 \n", + "31 27 \n", + "32 13 \n", + "33 1 \n", + "34 16 \n", + "35 5 \n", + "36 5 \n", + "37 18 \n", + "38 2 \n", + "39 7 \n", + "40 1 \n", + "41 9 \n", + "42 36 \n", + "43 4 \n", + "44 1 \n", + "45 11 \n", + "46 10 \n", + "47 3 \n", + "48 8 \n", + "49 1 \n", + "\n", + " CHANGE IN SEATS FROM CENSUS 2000 APPORTIONMENT \n", + "0 0 \n", + "1 0 \n", + "2 +1 \n", + "3 0 \n", + "4 0 \n", + "5 0 \n", + "6 0 \n", + "7 0 \n", + "8 +2 \n", + "9 +1 \n", + "10 0 \n", + "11 0 \n", + "12 -1 \n", + "13 0 \n", + "14 -1 \n", + "15 0 \n", + "16 0 \n", + "17 -1 \n", + "18 0 \n", + "19 0 \n", + "20 -1 \n", + "21 -1 \n", + "22 0 \n", + "23 0 \n", + "24 -1 \n", + "25 0 \n", + "26 0 \n", + "27 +1 \n", + "28 0 \n", + "29 -1 \n", + "30 0 \n", + "31 -2 \n", + "32 0 \n", + "33 0 \n", + "34 -2 \n", + "35 0 \n", + "36 0 \n", + "37 -1 \n", + "38 0 \n", + "39 +1 \n", + "40 0 \n", + "41 0 \n", + "42 +4 \n", + "43 +1 \n", + "44 0 \n", + "45 0 \n", + "46 +1 \n", + "47 0 \n", + "48 0 \n", + "49 0 " + ] + }, + "execution_count": 89, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "ca2010" + ] + }, + { + "cell_type": "code", + "execution_count": 93, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "ca2010['APPORTIONMENT POPULATION (APRIL 1, 2010)'] = ca2010['APPORTIONMENT POPULATION (APRIL 1, 2010)'].map(\n", + " lambda x: int(x.replace(',','')) if x != '' else 0)" + ] + }, + { + "cell_type": "code", + "execution_count": 94, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
STATEAPPORTIONMENT POPULATION (APRIL 1, 2010)NUMBER OF APPORTIONED REPRESENTATIVES BASED ON 2010 CENSUSCHANGE IN SEATS FROM CENSUS 2000 APPORTIONMENT
0ALABAMA480298270
1ALASKA72152310
2ARIZONA64127009+1
3ARKANSAS292622940
4CALIFORNIA37341989530
5COLORADO504493070
6CONNECTICUT358162850
7DELAWARE90087710
8FLORIDA1890077327+2
9GEORGIA972756614+1
\n", + "
" + ], + "text/plain": [ + " STATE APPORTIONMENT POPULATION (APRIL 1, 2010) \\\n", + "0 ALABAMA 4802982 \n", + "1 ALASKA 721523 \n", + "2 ARIZONA 6412700 \n", + "3 ARKANSAS 2926229 \n", + "4 CALIFORNIA 37341989 \n", + "5 COLORADO 5044930 \n", + "6 CONNECTICUT 3581628 \n", + "7 DELAWARE 900877 \n", + "8 FLORIDA 18900773 \n", + "9 GEORGIA 9727566 \n", + "\n", + " NUMBER OF APPORTIONED REPRESENTATIVES BASED ON 2010 CENSUS \\\n", + "0 7 \n", + "1 1 \n", + "2 9 \n", + "3 4 \n", + "4 53 \n", + "5 7 \n", + "6 5 \n", + "7 1 \n", + "8 27 \n", + "9 14 \n", + "\n", + " CHANGE IN SEATS FROM CENSUS 2000 APPORTIONMENT \n", + "0 0 \n", + "1 0 \n", + "2 +1 \n", + "3 0 \n", + "4 0 \n", + "5 0 \n", + "6 0 \n", + "7 0 \n", + "8 +2 \n", + "9 +1 " + ] + }, + "execution_count": 94, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "ca2010.head(10)" + ] + }, + { + "cell_type": "code", + "execution_count": 96, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "str" + ] + }, + "execution_count": 96, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "type(ca2010['NUMBER OF APPORTIONED REPRESENTATIVES BASED ON 2010 CENSUS'][3])" + ] + }, + { + "cell_type": "code", + "execution_count": 97, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "ca2010['NUMBER OF APPORTIONED REPRESENTATIVES BASED ON 2010 CENSUS'] = ca2010['NUMBER OF APPORTIONED REPRESENTATIVES BASED ON 2010 CENSUS'].map(\n", + " lambda x: int(x.replace(',','')) if x != '' else 0)" + ] + }, + { + "cell_type": "code", + "execution_count": 98, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "numpy.int64" + ] + }, + "execution_count": 98, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "type(ca2010['NUMBER OF APPORTIONED REPRESENTATIVES BASED ON 2010 CENSUS'][3])" + ] + }, + { + "cell_type": "code", + "execution_count": 99, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
STATEAPPORTIONMENT POPULATION (APRIL 1, 2010)NUMBER OF APPORTIONED REPRESENTATIVES BASED ON 2010 CENSUSCHANGE IN SEATS FROM CENSUS 2000 APPORTIONMENT
0ALABAMA480298270
1ALASKA72152310
2ARIZONA64127009+1
3ARKANSAS292622940
4CALIFORNIA37341989530
5COLORADO504493070
6CONNECTICUT358162850
7DELAWARE90087710
8FLORIDA1890077327+2
9GEORGIA972756614+1
\n", + "
" + ], + "text/plain": [ + " STATE APPORTIONMENT POPULATION (APRIL 1, 2010) \\\n", + "0 ALABAMA 4802982 \n", + "1 ALASKA 721523 \n", + "2 ARIZONA 6412700 \n", + "3 ARKANSAS 2926229 \n", + "4 CALIFORNIA 37341989 \n", + "5 COLORADO 5044930 \n", + "6 CONNECTICUT 3581628 \n", + "7 DELAWARE 900877 \n", + "8 FLORIDA 18900773 \n", + "9 GEORGIA 9727566 \n", + "\n", + " NUMBER OF APPORTIONED REPRESENTATIVES BASED ON 2010 CENSUS \\\n", + "0 7 \n", + "1 1 \n", + "2 9 \n", + "3 4 \n", + "4 53 \n", + "5 7 \n", + "6 5 \n", + "7 1 \n", + "8 27 \n", + "9 14 \n", + "\n", + " CHANGE IN SEATS FROM CENSUS 2000 APPORTIONMENT \n", + "0 0 \n", + "1 0 \n", + "2 +1 \n", + "3 0 \n", + "4 0 \n", + "5 0 \n", + "6 0 \n", + "7 0 \n", + "8 +2 \n", + "9 +1 " + ] + }, + "execution_count": 99, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "ca2010.head(10)" + ] + }, + { + "cell_type": "code", + "execution_count": 100, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "ca2010['TOTAL ELECTORAL VOTES'] = ca2010['NUMBER OF APPORTIONED REPRESENTATIVES BASED ON 2010 CENSUS'] + 2" + ] + }, + { + "cell_type": "code", + "execution_count": 102, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
STATEAPPORTIONMENT POPULATION (APRIL 1, 2010)NUMBER OF APPORTIONED REPRESENTATIVES BASED ON 2010 CENSUSCHANGE IN SEATS FROM CENSUS 2000 APPORTIONMENTTOTAL ELECTORAL VOTES
0ALABAMA4802982709
1ALASKA721523103
2ARIZONA64127009+111
3ARKANSAS2926229406
4CALIFORNIA3734198953055
5COLORADO5044930709
6CONNECTICUT3581628507
7DELAWARE900877103
8FLORIDA1890077327+229
9GEORGIA972756614+116
\n", + "
" + ], + "text/plain": [ + " STATE APPORTIONMENT POPULATION (APRIL 1, 2010) \\\n", + "0 ALABAMA 4802982 \n", + "1 ALASKA 721523 \n", + "2 ARIZONA 6412700 \n", + "3 ARKANSAS 2926229 \n", + "4 CALIFORNIA 37341989 \n", + "5 COLORADO 5044930 \n", + "6 CONNECTICUT 3581628 \n", + "7 DELAWARE 900877 \n", + "8 FLORIDA 18900773 \n", + "9 GEORGIA 9727566 \n", + "\n", + " NUMBER OF APPORTIONED REPRESENTATIVES BASED ON 2010 CENSUS \\\n", + "0 7 \n", + "1 1 \n", + "2 9 \n", + "3 4 \n", + "4 53 \n", + "5 7 \n", + "6 5 \n", + "7 1 \n", + "8 27 \n", + "9 14 \n", + "\n", + " CHANGE IN SEATS FROM CENSUS 2000 APPORTIONMENT TOTAL ELECTORAL VOTES \n", + "0 0 9 \n", + "1 0 3 \n", + "2 +1 11 \n", + "3 0 6 \n", + "4 0 55 \n", + "5 0 9 \n", + "6 0 7 \n", + "7 0 3 \n", + "8 +2 29 \n", + "9 +1 16 " + ] + }, + "execution_count": 102, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "ca2010.head(10)" + ] + }, + { + "cell_type": "code", + "execution_count": 103, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "ca2010['NUMBER OF CITIZENS PER ELECTORAL VOTE'] = ca2010['APPORTIONMENT POPULATION (APRIL 1, 2010)']/ca2010['TOTAL ELECTORAL VOTES']" + ] + }, + { + "cell_type": "code", + "execution_count": 104, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
STATEAPPORTIONMENT POPULATION (APRIL 1, 2010)NUMBER OF APPORTIONED REPRESENTATIVES BASED ON 2010 CENSUSCHANGE IN SEATS FROM CENSUS 2000 APPORTIONMENTTOTAL ELECTORAL VOTESNUMBER OF CITIZENS PER ELECTORAL VOTE
0ALABAMA4802982709533664.666667
1ALASKA721523103240507.666667
2ARIZONA64127009+111582972.727273
3ARKANSAS2926229406487704.833333
4CALIFORNIA3734198953055678945.254545
5COLORADO5044930709560547.777778
6CONNECTICUT3581628507511661.142857
7DELAWARE900877103300292.333333
8FLORIDA1890077327+229651750.793103
9GEORGIA972756614+116607972.875000
\n", + "
" + ], + "text/plain": [ + " STATE APPORTIONMENT POPULATION (APRIL 1, 2010) \\\n", + "0 ALABAMA 4802982 \n", + "1 ALASKA 721523 \n", + "2 ARIZONA 6412700 \n", + "3 ARKANSAS 2926229 \n", + "4 CALIFORNIA 37341989 \n", + "5 COLORADO 5044930 \n", + "6 CONNECTICUT 3581628 \n", + "7 DELAWARE 900877 \n", + "8 FLORIDA 18900773 \n", + "9 GEORGIA 9727566 \n", + "\n", + " NUMBER OF APPORTIONED REPRESENTATIVES BASED ON 2010 CENSUS \\\n", + "0 7 \n", + "1 1 \n", + "2 9 \n", + "3 4 \n", + "4 53 \n", + "5 7 \n", + "6 5 \n", + "7 1 \n", + "8 27 \n", + "9 14 \n", + "\n", + " CHANGE IN SEATS FROM CENSUS 2000 APPORTIONMENT TOTAL ELECTORAL VOTES \\\n", + "0 0 9 \n", + "1 0 3 \n", + "2 +1 11 \n", + "3 0 6 \n", + "4 0 55 \n", + "5 0 9 \n", + "6 0 7 \n", + "7 0 3 \n", + "8 +2 29 \n", + "9 +1 16 \n", + "\n", + " NUMBER OF CITIZENS PER ELECTORAL VOTE \n", + "0 533664.666667 \n", + "1 240507.666667 \n", + "2 582972.727273 \n", + "3 487704.833333 \n", + "4 678945.254545 \n", + "5 560547.777778 \n", + "6 511661.142857 \n", + "7 300292.333333 \n", + "8 651750.793103 \n", + "9 607972.875000 " + ] + }, + "execution_count": 104, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "ca2010.head(10)" + ] + }, + { + "cell_type": "code", + "execution_count": 105, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "ca2010['NUMBER OF CITIZENS PER ELECTORAL VOTE'] = ca2010['NUMBER OF CITIZENS PER ELECTORAL VOTE'].map(lambda x: int(x))" + ] + }, + { + "cell_type": "code", + "execution_count": 106, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
STATEAPPORTIONMENT POPULATION (APRIL 1, 2010)NUMBER OF APPORTIONED REPRESENTATIVES BASED ON 2010 CENSUSCHANGE IN SEATS FROM CENSUS 2000 APPORTIONMENTTOTAL ELECTORAL VOTESNUMBER OF CITIZENS PER ELECTORAL VOTE
0ALABAMA4802982709533664
1ALASKA721523103240507
2ARIZONA64127009+111582972
3ARKANSAS2926229406487704
4CALIFORNIA3734198953055678945
5COLORADO5044930709560547
6CONNECTICUT3581628507511661
7DELAWARE900877103300292
8FLORIDA1890077327+229651750
9GEORGIA972756614+116607972
\n", + "
" + ], + "text/plain": [ + " STATE APPORTIONMENT POPULATION (APRIL 1, 2010) \\\n", + "0 ALABAMA 4802982 \n", + "1 ALASKA 721523 \n", + "2 ARIZONA 6412700 \n", + "3 ARKANSAS 2926229 \n", + "4 CALIFORNIA 37341989 \n", + "5 COLORADO 5044930 \n", + "6 CONNECTICUT 3581628 \n", + "7 DELAWARE 900877 \n", + "8 FLORIDA 18900773 \n", + "9 GEORGIA 9727566 \n", + "\n", + " NUMBER OF APPORTIONED REPRESENTATIVES BASED ON 2010 CENSUS \\\n", + "0 7 \n", + "1 1 \n", + "2 9 \n", + "3 4 \n", + "4 53 \n", + "5 7 \n", + "6 5 \n", + "7 1 \n", + "8 27 \n", + "9 14 \n", + "\n", + " CHANGE IN SEATS FROM CENSUS 2000 APPORTIONMENT TOTAL ELECTORAL VOTES \\\n", + "0 0 9 \n", + "1 0 3 \n", + "2 +1 11 \n", + "3 0 6 \n", + "4 0 55 \n", + "5 0 9 \n", + "6 0 7 \n", + "7 0 3 \n", + "8 +2 29 \n", + "9 +1 16 \n", + "\n", + " NUMBER OF CITIZENS PER ELECTORAL VOTE \n", + "0 533664 \n", + "1 240507 \n", + "2 582972 \n", + "3 487704 \n", + "4 678945 \n", + "5 560547 \n", + "6 511661 \n", + "7 300292 \n", + "8 651750 \n", + "9 607972 " + ] + }, + "execution_count": 106, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "ca2010.head(10)" + ] + }, + { + "cell_type": "code", + "execution_count": 107, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "ca2010.to_csv('2010_apportionment_cleaned.tsv', sep = '\\t', index=False)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] + } + ], + "metadata": { + "anaconda-cloud": {}, + "kernelspec": { + "display_name": "Python [Root]", + "language": "python", + "name": "Python [Root]" + }, + "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": 2 +}