Last active
June 9, 2017 21:20
-
-
Save leggitta/02f15e5cc7f1bee20b0a016e6881cbc3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bokeh.plotting import figure, show | |
from bokeh.io import output_file | |
import numpy as np | |
import pandas as pd | |
output_file('n_filings.html') | |
# read the filing data | |
filings = pd.read_csv('filings.csv') | |
# compute number of filings and names per committee id | |
n_filings = filings.groupby('fec_committee_id').filing_id.nunique() | |
n_names = filings.groupby('fec_committee_id').committee_name.nunique() | |
n_committees = len(n_filings) | |
# save the committee data | |
committee_data = pd.concat([n_filings, n_names], axis=1) | |
committee_data.columns = ('n_filings', 'n_names') | |
committee_data.to_csv('committee_data.csv') | |
# compute the log histogram | |
hist, edges = np.histogram(n_filings, bins=np.logspace(0, 3, 15)) | |
# plot log histogram | |
fig = figure( | |
width=600, height=500, toolbar_location=None, x_axis_type="log", | |
title="Filings Per Committee", background_fill_color='oldlace') | |
fig.title.text_font = "times" | |
fig.title.text_font_size = "16pt" | |
fig.quad(top=hist, bottom=0, left=edges[:-1], right=edges[1:], | |
line_color='black', fill_color='seagreen') | |
fig.xaxis.axis_label = "Number of Filings" | |
fig.xaxis.axis_label_text_font = "times" | |
fig.xaxis.axis_label_text_font_size = "12pt" | |
fig.yaxis.axis_label = "Committee Count" | |
fig.yaxis.axis_label_text_font = "times" | |
fig.yaxis.axis_label_text_font_size = "12pt" | |
show(fig) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Generates the following plot ....