bills-sponsor-party

Created by: SmirkyGraphs. Code: Github. Source: RI Legislature Site.


RI Bills by Sponsors Party and Outcome

Its no secret that Rhode Island's legislature leans overwhelmingly in the favor of Democrats. With the House having only 9 Republicans and the Senate only 5. Naturally with the chambers being overwhelmingly Democrat the bills going through and becoming law will primarily be in their favor. However, I wanted to see just how many bills introduced by Republicans go on to pass both chambers and become law. Also, how often the parties work together on Bi-Partisan bills and how all of these metrics have changed over the years since 2007.

This notebook will take a look at the sponsors party of every bill introduced since 2007, aggregate it and group it by year. Finally, it will look at the final outcome of all bills introduced since 2007 and count how many went on to become law.

Total Number of Bills by Sponsor Party

In [1]:
import pandas as pd
import numpy as np
In [2]:
df = pd.read_csv('../data/clean/bill_info.csv')

# removes resolutions (6112)
df = df[~df['bill_id'].str.contains('R')]

# removes bills that had independents (200)
df = df[df['bill_party'] != 'other']

# remove solemnization of marriage (1223)
df = df[~df['title'].str.contains('RELATING TO SOLEMNIZATION OF MARRIAGES')]
In [3]:
# filter on only wanted columns
cols = ['lookup_id', 'session', 'bill_party', 'origin']
df = df[cols]
In [4]:
# create a pivot table of bills by partisanship
table = df.pivot_table(index=['origin', 'session'], columns='bill_party', aggfunc='count', fill_value=0)
In [5]:
# fix table header formating
table.columns = table.columns.droplevel()
table = table.rename_axis([None, None])
table.columns.name = None

# adding a total column
table['total'] = table.sum(axis=1)
In [6]:
table
Out[6]:
bi-partisan democrat republican total
house 2007 200 917 132 1249
2008 218 812 112 1142
2009 118 891 63 1072
2010 119 819 40 978
2011 197 781 20 998
2012 155 801 22 978
2013 114 837 42 993
2014 118 879 32 1029
2015 170 744 34 948
2016 133 849 34 1016
2017 138 853 69 1060
2018 175 823 61 1059
2019 92 755 81 928
senate 2007 138 760 55 953
2008 138 735 77 950
2009 99 712 37 848
2010 109 653 17 779
2011 164 611 47 822
2012 181 596 37 814
2013 179 571 33 783
2014 176 647 15 838
2015 145 606 22 773
2016 133 717 42 892
2017 77 711 23 811
2018 108 665 14 787
2019 95 670 13 778
In [7]:
# getting table as percentages
percent_table = table.div(table['total'], axis='index')

# formatting as percentages
percent_table['bi-partisan'] = percent_table['bi-partisan'].map(lambda n: '{:,.1%}'.format(n))
percent_table['democrat'] = percent_table['democrat'].map(lambda n: '{:,.1%}'.format(n))
percent_table['republican'] = percent_table['republican'].map(lambda n: '{:,.1%}'.format(n))

# removing total
percent_table = percent_table.drop(columns='total')
In [8]:
percent_table
Out[8]:
bi-partisan democrat republican
house 2007 16.0% 73.4% 10.6%
2008 19.1% 71.1% 9.8%
2009 11.0% 83.1% 5.9%
2010 12.2% 83.7% 4.1%
2011 19.7% 78.3% 2.0%
2012 15.8% 81.9% 2.2%
2013 11.5% 84.3% 4.2%
2014 11.5% 85.4% 3.1%
2015 17.9% 78.5% 3.6%
2016 13.1% 83.6% 3.3%
2017 13.0% 80.5% 6.5%
2018 16.5% 77.7% 5.8%
2019 9.9% 81.4% 8.7%
senate 2007 14.5% 79.7% 5.8%
2008 14.5% 77.4% 8.1%
2009 11.7% 84.0% 4.4%
2010 14.0% 83.8% 2.2%
2011 20.0% 74.3% 5.7%
2012 22.2% 73.2% 4.5%
2013 22.9% 72.9% 4.2%
2014 21.0% 77.2% 1.8%
2015 18.8% 78.4% 2.8%
2016 14.9% 80.4% 4.7%
2017 9.5% 87.7% 2.8%
2018 13.7% 84.5% 1.8%
2019 12.2% 86.1% 1.7%

Bills by Sponsors Party - Became Law

In [9]:
df = pd.read_csv('../data/clean/bill_info.csv')
In [10]:
# removes resolutions (6112)
df = df[~df['bill_id'].str.contains('R')]

# removes bills that had independents (200)
df = df[df['bill_party'] != 'other']

# removes bills that never became law (5867)
df = df[~df['relevant_dates.became_law'].isnull()]

# removes solemnization of marriages (1177)
df = df[~df['title'].str.contains('RELATING TO SOLEMNIZATION OF MARRIAGES')]
In [11]:
# filter on only wanted columns
cols = ['lookup_id', 'session', 'bill_party', 'origin']
df = df[cols]
In [12]:
# create a pivot table of bills by partisanship
table = df.pivot_table(index=['origin', 'session'], columns='bill_party', aggfunc='count', fill_value=0)
In [13]:
# fix table header formating
table.columns = table.columns.droplevel()
table = table.rename_axis([None, None])
table.columns.name = None

# adding a total column
table['total'] = table.sum(axis=1)

table
Out[13]:
bi-partisan democrat republican total
house 2007 47 218 31 296
2008 50 193 16 259
2009 26 179 16 221
2010 19 148 5 172
2011 39 193 6 238
2012 29 235 4 268
2013 24 260 3 287
2014 26 262 7 295
2015 22 128 7 157
2016 24 263 8 295
2017 24 232 10 266
2018 28 185 6 219
2019 4 55 2 61
senate 2007 36 210 23 269
2008 41 178 26 245
2009 32 152 15 199
2010 18 144 7 169
2011 40 169 12 221
2012 44 200 17 261
2013 54 206 12 272
2014 67 201 8 276
2015 24 114 4 142
2016 35 218 14 267
2017 21 243 7 271
2018 14 183 3 200
2019 6 48 1 55
In [14]:
# getting table as percentages
percent_table = table.div(table['total'], axis='index')

# formatting as percentages
percent_table['bi-partisan'] = percent_table['bi-partisan'].map(lambda n: '{:,.1%}'.format(n))
percent_table['democrat'] = percent_table['democrat'].map(lambda n: '{:,.1%}'.format(n))
percent_table['republican'] = percent_table['republican'].map(lambda n: '{:,.1%}'.format(n))

# removing total
percent_table = percent_table.drop(columns='total')
In [15]:
percent_table
Out[15]:
bi-partisan democrat republican
house 2007 15.9% 73.6% 10.5%
2008 19.3% 74.5% 6.2%
2009 11.8% 81.0% 7.2%
2010 11.0% 86.0% 2.9%
2011 16.4% 81.1% 2.5%
2012 10.8% 87.7% 1.5%
2013 8.4% 90.6% 1.0%
2014 8.8% 88.8% 2.4%
2015 14.0% 81.5% 4.5%
2016 8.1% 89.2% 2.7%
2017 9.0% 87.2% 3.8%
2018 12.8% 84.5% 2.7%
2019 6.6% 90.2% 3.3%
senate 2007 13.4% 78.1% 8.6%
2008 16.7% 72.7% 10.6%
2009 16.1% 76.4% 7.5%
2010 10.7% 85.2% 4.1%
2011 18.1% 76.5% 5.4%
2012 16.9% 76.6% 6.5%
2013 19.9% 75.7% 4.4%
2014 24.3% 72.8% 2.9%
2015 16.9% 80.3% 2.8%
2016 13.1% 81.6% 5.2%
2017 7.7% 89.7% 2.6%
2018 7.0% 91.5% 1.5%
2019 10.9% 87.3% 1.8%