Created
August 3, 2019 20:59
-
-
Save bchauSW/a33ec0e6036063b8349f20dacd9d6adb to your computer and use it in GitHub Desktop.
This script extracts the demographics from this website and formats it into a readable format: https://www.fjc.gov/history/judges/biographical-directory-article-iii-federal-judges-export
This file contains 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
import pandas as pd | |
from collections import Counter | |
df = pd.read_csv('judges.csv') | |
fields = ['Birth State', 'Gender', 'Race or Ethnicity', 'Party of Appointing President (1)'] | |
for field in fields: | |
counts = Counter(df[field]).most_common() | |
with open(field + '.csv', 'w+') as f: | |
for count in counts: | |
f.write(str(count[0]) + ',' + str(count[1]) + '\n') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment