Finances of Members of Congress

Anthony Ozerov's Website 🤔 / Research Papers Projects Thoughts About

I found some data[1] on the net worths of members of Congress (in 2018) at the website of the Center for Responsive Politics. Unfortunately, this data is in a big HTML table and I could not find a spreadsheet or anything. I wrote some code in Python to scrape the webpage and do a little bit of analysis:

import pandas as pd
import requests

r
=requests.get("https://www.opensecrets.org/personal-finances/top-net-worth")
df
=pd.DataFrame(pd.read_html(r.text)[0])

df
["Average"] = df["Average"].replace('[\$,]', '', regex=True).astype(float)

dem
=df[df['Name'].str.contains("D-")]
rep
=df[df['Name'].str.contains("R-")]


print("Median for Democrat members of Congress:   $"+str(dem["Average"].median()))
print("Median for Republican members of Congress: $"+str(rep["Average"].median()))
Median for Democrat members of Congress:   $1165006.5
Median for Republican members of Congress: $1191022.0

Python file: networth.py

IPython notebook networth.ipynb


[1]“Net Worth - 2018.” OpenSecrets, The Center for Responsive Politics, https://www.opensecrets.org/personal-finances/top-net-worth. Accessed 12 Mar. 2021.