In [2]:
#apply styles to notebook (rather than doing it locally 
# via the profile custom.css file)
#from IPython.core.display import HTML
#css_file = 'media/style.css'
#HTML(open(css_file, "r").read())

U.S. Federal Contracts

Federal Contracts

In [3]:
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib as mpl
import matplotlib.pyplot as plt
%matplotlib inline

Data Notes

  • Source: USASpending.gov
  • Full 08-15-2014 contract archives for 2007 - 2013
  • Primary awards only
  • Aggregated by:
    • State (location of work)
    • Agency (primary contracting agency)
  • Inflation-adjusted using OMB's Budget Request deflators
  • Per-capita numbers calculated using vintage 2013 Census population estimates
In [4]:
#read in aggregated federal contract totals
contracts = pd.read_csv('data/fed_contract_totals.txt')
contracts = contracts[[
    'state_abbr', 'year', 'total_adj', 'dod_adj', 
    'non-dod_adj', 'total_per_capita_adj', 'dod_per_capita_adj',
    'other_per_capita_adj', 'dod_percent_total', 'other_percent_total'
]]
#take a peek at the data
contracts.head()
Out[4]:
state_abbr year total_adj dod_adj non-dod_adj total_per_capita_adj dod_per_capita_adj other_per_capita_adj dod_percent_total other_percent_total
0 AK 2012 2.566977e+09 2.118944e+09 4.480333e+08 3514.933976 2901.446238 613.487738 82.55 17.45
1 AK 2013 1.678331e+09 1.320963e+09 3.573687e+08 2283.037374 1796.902746 486.124303 78.71 21.29
2 AK 2011 2.412034e+09 1.942390e+09 4.696442e+08 3334.420985 2685.178076 649.242909 80.53 19.47
3 AK 2007 2.672470e+09 2.124680e+09 5.477898e+08 3928.365983 3123.157060 805.220247 79.50 20.50
4 AK 2009 3.086416e+09 2.406223e+09 6.801932e+08 4416.142121 3442.899441 973.242680 77.96 22.04

Dept. of Defense (DoD) and Non-DoD Over Time

In [7]:
plottotal = contracts[['year', 'state_abbr', 'dod_adj', 'non-dod_adj']]
#show total in millions of $ for readability
plottotal['dod_adj'] = plottotal['dod_adj']/1000000
plottotal['non-dod_adj'] = plottotal['non-dod_adj']/1000000
plottotal = pd.melt(plottotal, id_vars=['year', 'state_abbr'], var_name = 'Contract Type', value_name = 'Amount')
fg = sns.factorplot('year', 'Amount', 'Contract Type',data=plottotal[plottotal['state_abbr']=='VA'], kind='bar')
fg.set_axis_labels('Fiscal Year', 'Amount (Millions of 2015 $)')
Out[7]:
<seaborn.axisgrid.FacetGrid at 0x1bf58cf8>

By State

In [6]:
plotpc = contracts[['year', 'state_abbr', 'dod_per_capita_adj', 'other_per_capita_adj']]
plotpc = pd.melt(plotpc, id_vars=['year', 'state_abbr'], var_name = 'Contract Type', value_name = 'Amount')
fg = sns.factorplot(
    'year', 'Amount', 'Contract Type',
    plotpc[~plotpc['state_abbr'].isin(['DC', 'PR'])],
    col='state_abbr', col_wrap=4, kind='point'
    )
fg.set_axis_labels('Fiscal Year', 'Amount (2015 $)')
Out[6]:
<seaborn.axisgrid.FacetGrid at 0x17406128>