Counting Presidential Signatures in U.S. Law with Python

Browsing through U.S Law, I noticed that there are many notes- e.g. memos to Federal employees and executive orders. In some cases these have a signature block, which shows who wrote the document. Most, but not all, are written by presidents. I suspect that either the inclusion of these records in U.S. Law (or at least the signatures) is relatively modern, as the oldest person with multiple signatures is Harry Truman- these are somewhat, but not entirely chronological.

Barack Obama: 183
William J. Clinton: 159
George W. Bush: 147
Jimmy Carter: 65
Ronald Reagan: 59
George Bush: 55 
Richard Nixon: 37
Dwight D. Eisenhower: 32
Lyndon B. Johnson: 28
Gerald R. Ford: 17
Harry S Truman: 13 
John F. Kennedy: 10
Harry S. Truman: 7
Franklin D. Roosevelt: 4
Fred M. Vinson: 1
Halifax.: 1
Nancy Pelosi: 1
Wm. H. Taft.: 1
Robert F. Kennedy: 1
By Alexander C. Hoffman: 1
Franklin D Roosevelt: 1
Robert C. Byrd: 1
By Sheldon Elliott Steinbach: 1
Edward DLG. Pangelinan': 1
By Irwin Karp: 1 
Ambassador F. Haydn Williams: 1
Robert S. McNamara: 1
J. C. Lambert: 1

This output can be easily generated in Python, like so:

all_signatures = []
def findElements(xpath, urls):
  for root, dirs, files in os.walk(dir):
    for f in files:
      if f.endswith('.xml'):
        tree = ET.parse(dir + "\\" + f)
        namepath = './/{http://xml.house.gov/schemas/uslm/1.0}name'
        sigpath = './/{http://xml.house.gov/schemas/uslm/1.0}signature'
        signatures = 
           [n.find(namepath).text \ 
           for n in tree.findall(sigpath)]
        print(f)
        print(Counter(signatures))
        all_signatures = all_signatures + signatures

print("All:")
print(Counter(all_signatures))

The distribution of these is interesting as well, as certain titles are represented much more than others (it would be best to normalize these by the length or age of the title, although that may be less useful given the recency bias of the signatures).

The two largest (Title 22, Title 42) are “Foreign Relations and Intercourse” and “The Public Health and Welfare”.

Title 01: 3 memos
Title 02: 10 memos
Title 03: 24 memos
Title 04: 2 memos
Title 05: 87 memos
Title 06: 14 memos
Title 07: 17 memos
Title 08: 19 memos
Title 09: 0 memos
Title 10: 36 memos
Title 11: 0 memos
Title 12: 9 memos
Title 13: 0 memos
Title 14: 0 memos
Title 15: 48 memos
Title 16: 27 memos
Title 17: 5 memos
Title 18: 10 memos
Title 19: 40 memos
Title 20: 16 memos
Title 21: 5 memos
Title 22: 114 memos
Title 23: 3 memos
Title 24: 1 memos
Title 25: 5 memos
Title 26: 8 memos
Title 27: 0 memos
Title 28: 14 memos
Title 29: 11 memos
Title 30: 1 memos
Title 31: 28 memos
Title 32: 2 memos
Title 33: 10 memos
Title 35: 1 memos
Title 36: 8 memos
Title 37: 2 memos
Title 38: 8 memos
Title 39: 2 memos
Title 40: 12 memos
Title 41: 14 memos
Title 42: 122 memos
Title 43: 6 memos
Title 44: 6 memos
Title 45: 1 memos
Title 46: 1 memos
Title 47: 5 memos
Title 48: 20 memos
Title 49: 19 memos
Title 50: 33 memos
Title 51: 6 memos