When working on my semester project for Network Analysis I realized there are a significant number of existing data sets and raw data (amazing), but very few tools which help researchers scrape and organize their own data.
So, I thought I’d share some code which I used in order to scrape and create the network of cosponsorships for the 116th Congress.
You’ll find the code here: https://github.com/caramnix/polymath
So, this code will just get you the adjacency matrix. Let’s quickly define/go over how to interpret this adjacency matrix…
And after outputting the adjacency matrix in Python I personally switched to R to plot it (obligatory network plot below).
To clarify how to interpret this plot,
But, more interesting (at least to me) is if we color the nodes based on Party, we see a stark divide between the parties.
What does this mean? Well, we know Congress is polarized, and (clearly) cosponsorships accurately reflect that polarization!
Cool!
The code also allows one to look at who sponsored the most legislation for the 116th Congress:
And who received the most cosponsors from their colleagues:
If you have any questions or the code isn’t working (/isn’t clear) let me know!