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¶
import pandas as pd
import numpy as np
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')]
# filter on only wanted columns
cols = ['lookup_id', 'session', 'bill_party', 'origin']
df = df[cols]
# create a pivot table of bills by partisanship
table = df.pivot_table(index=['origin', 'session'], columns='bill_party', aggfunc='count', fill_value=0)
# 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
# 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')
percent_table
Bills by Sponsors Party - Became Law¶
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']
# 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')]
# filter on only wanted columns
cols = ['lookup_id', 'session', 'bill_party', 'origin']
df = df[cols]
# create a pivot table of bills by partisanship
table = df.pivot_table(index=['origin', 'session'], columns='bill_party', aggfunc='count', fill_value=0)
# 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
# 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')
percent_table