It turns out that Wikipedia has a page on firearm death rates by state. That page has a nice little table for death rates per 100,000 population in 2013. Furthermore, there is also a page on gun laws per state.

Let's do something stupidly simple: Let's count up the gun laws in each state, and compare it to the firearm death rates.

This is obviously a very flawed metric, but it serves as a good initial sanity check. I expect there to be a pretty strong negative relation - the more gun control laws, the less gun-related deaths. If that is found, then sanity check passed, and barring more in-depth research showing otherwise, I can accept that adding gun control laws could plausibly decrease the gun death rate.

Scraping the wikipedia articles turns out to be surprisingly easy using pandas:

In [107]:

```
import pandas as pd
# Read the tables from the wikipedia page, and return the second one (index 1), which corresponds to the
# gun death rate per state.
gun_death_rate = pd.read_html("https://en.wikipedia.org/wiki/Firearm_death_rates_in_the_United_States_by_state",
header=0,
attrs={"class": ["sortable","wikitable", "plainrowheaders"]})[1]
# Read the tables from the gun laws wikipedia page, and return the 51 tables corresponding to the gun laws
# in each state, plus the district of columbia
per_state_gun_laws = pd.read_html("https://en.wikipedia.org/wiki/Gun_laws_in_the_United_States_by_state",header=0)[1:-7]
```

Now we combine the two datasets by just counting the laws per state:

In [113]:

```
# Let's extract the number of restrictions (ie, count the number of laws) for each state
number_of_restrictions_per_state = []
for state_laws in per_state_gun_laws:
# Everywhere there is a "Yes", we say that there is an additional restriction,
# except for the "open carry" row, which is reversed, disallowing open carry is
# a restriction
open_carry_row = (state_laws[state_laws["Subject/Law"].str.contains("Open carry|Open Carry")].index[0])
handgun_restrictions = (state_laws["Handguns"].str.contains("Yes")
+ 0.5*state_laws["Handguns"].str.contains("Partial"))
handgun_restrictions[open_carry_row] = 1 - handgun_restrictions[open_carry_row]
# Annoyingly, wikipedia uses two different table headings
try:
longgun_restrictions = (state_laws["Long Guns"].str.contains("Yes")
+ 0.5*state_laws["Long Guns"].str.contains("Partial"))
except:
longgun_restrictions = (state_laws["Long guns"].str.contains("Yes")
+ 0.5*state_laws["Long guns"].str.contains("Partial"))
longgun_restrictions[open_carry_row] = 1 - longgun_restrictions[open_carry_row]
number_of_restrictions_per_state.append(handgun_restrictions.sum() + longgun_restrictions.sum())
# Thankfully the states are alphabetical in both wikipedia pages, so they match up without any more work.
# We just need to remove the district of columbia (8th element, 0-indexed)
del number_of_restrictions_per_state[8]
full_dataset = gun_death_rate.assign(Laws=number_of_restrictions_per_state)
# Now a bit of cleanup:
# Winsconsin has a weird table, which we need to fix manually
full_dataset.loc[full_dataset["State"]=="Wisconsin","Laws"] += 3
full_dataset
```

Out[113]:

So, let's plot it!

In [114]:

```
%matplotlib inline
import seaborn as sb
sb.regplot(x="Laws",y="Rate",data=full_dataset)
```

Out[114]:

Given the large negative correlation, unless research is sent to me with a more in-depth analysis of the issue, I can accept that it is very plausible^{1} that adding gun control laws would decrease the firearm death rate.

Correlation does not imply causation.↩

In [ ]:

```
```