Skip to content

Instantly share code, notes, and snippets.

@bchauSW
Created August 3, 2019 20:59
Show Gist options
  • Save bchauSW/a33ec0e6036063b8349f20dacd9d6adb to your computer and use it in GitHub Desktop.
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
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