In [1]:
sys.path.append(os.path.join(os.path.abspath('../..'), 'src'))
sys.path.append(os.path.join(os.path.abspath('../..'), 'data'))

In [2]:
import pandas

In [3]:
import utils

In [4]:
rep_data = utils.load_rep_data()

In [5]:
rep_data.head()


Out[5]:
Party District Member Counties Represented
0 (R) District 96 Jay Adams Catawba
1 (D) District 41 Gale Adcock Wake
2 (D) District 115 John Ager Buncombe
3 (D) District 107 Kelly M. Alexander, Jr. Mecklenburg
4 (R) District 69 Dean Arp Union

In [6]:
sen_data = utils.load_senator_data()

In [7]:
sen_data.head()


Out[7]:
Party District Member Counties Represented
0 (R) District 15 John M. Alexander, Jr. Wake
1 (R) District 45 Deanna Ballard Alleghany, Ashe, Avery, Caldwell, Watauga
2 (R) District 18 Chad Barefoot Franklin, Wake
3 (R) District 17 Tamara Barringer Wake
4 (R) District 26 Phil Berger Guilford, Rockingham

2016 Election Data


In [8]:
sen2016 = utils.load_election_data('senate')

In [9]:
sen2016.head()


Out[9]:
District Session Chamber Name Party Incombant Won Votes
0 1 2016 S Brownie Futrell D False False 36,759
1 1 2016 S William Cook R True True 53,138
2 2 2016 S Dorothea White D False False 39,505
3 2 2016 S Norman Sanderson R True True 58,032
4 3 2016 S Erica Smith-Ingram D True True NA

In [10]:
sen2016.shape


Out[10]:
(88, 8)

In [11]:
sen2016.ix[0].to_dict()


Out[11]:
{'Chamber': 'S',
 'District': '1',
 'Incombant': False,
 'Name': 'Brownie Futrell',
 'Party': 'D',
 'Session': '2016',
 'Votes': '36,759',
 'Won': False}

In [12]:
hou2016 = utils.load_election_data('house')

In [13]:
hou2016.head()


Out[13]:
District Session Chamber Name Party Incombant Won Votes
0 1 2016 H Sam Davis D False False 12,240
1 1 2016 H Bob Steinburg R True True 25,363
2 2 2016 H Joe Parrish D False False 14,775
3 2 2016 H Larry Yarborough R True True 22,760
4 3 2016 H Marva Fisher Baldwin D False False 12,638

In [14]:
hou2016.shape


Out[14]:
(189, 8)

In [15]:
hou2016.ix[0].to_dict()


Out[15]:
{'Chamber': 'H',
 'District': '1',
 'Incombant': False,
 'Name': 'Sam Davis',
 'Party': 'D',
 'Session': '2016',
 'Votes': '12,240',
 'Won': False}

2014 Elections Data


In [16]:
sen2014 = utils.load_election_data('senate', '2014')

In [17]:
sen2014.head()


Out[17]:
District Session Chamber Name Party Incombant Won Votes
0 1 2014 S Stan White D NA False 27,957
1 1 2014 S Bill Cook R NA True 32,143
2 2 2014 S Carroll Ipock II D NA False 23,925
3 2 2014 S Norman Sanderson R NA True 36,562
4 3 2014 S Erica Smith-Ingram D NA True NA

In [18]:
sen2014.shape


Out[18]:
(82, 8)

In [19]:
sen2014.ix[0].to_dict()


Out[19]:
{'Chamber': 'S',
 'District': '1',
 'Incombant': 'NA',
 'Name': 'Stan White',
 'Party': 'D',
 'Session': '2014',
 'Votes': '27,957',
 'Won': False}

In [20]:
hou2014 = utils.load_election_data('house', '2014')

In [21]:
hou2014.head()


Out[21]:
District Session Chamber Name Party Incombant Won Votes
0 1 2014 H Garry Meiggs D NA False 10,082
1 1 2014 H Bob Steinburg R NA True 15,713
2 2 2014 H Ray Jeffers D NA False 10,259
3 2 2014 H Larry Yarborough R NA True 13,423
4 3 2014 H Whit Whitley D NA False 10,524

In [22]:
hou2014.shape


Out[22]:
(182, 8)

In [23]:
hou2014.ix[0].to_dict()


Out[23]:
{'Chamber': 'H',
 'District': '1',
 'Incombant': 'NA',
 'Name': 'Garry Meiggs',
 'Party': 'D',
 'Session': '2014',
 'Votes': '10,082',
 'Won': False}

In [ ]: