{"id":16615058,"url":"https://github.com/dschep/executive-orders-notebook","last_synced_at":"2025-12-16T06:08:07.655Z","repository":{"id":140936072,"uuid":"80934989","full_name":"dschep/executive-orders-notebook","owner":"dschep","description":"A Jupyter Notebook to play with how many Executive Orders Presidents have signed","archived":false,"fork":false,"pushed_at":"2018-04-25T20:05:12.000Z","size":800,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-17T16:55:59.244Z","etag":null,"topics":["data-visualization","jupyter","jupyter-notebook","trump"],"latest_commit_sha":null,"homepage":null,"language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dschep.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-02-04T17:20:17.000Z","updated_at":"2018-04-25T20:05:13.000Z","dependencies_parsed_at":null,"dependency_job_id":"31c77370-a35b-4fba-9ee4-77311cb1d2af","html_url":"https://github.com/dschep/executive-orders-notebook","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dschep%2Fexecutive-orders-notebook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dschep%2Fexecutive-orders-notebook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dschep%2Fexecutive-orders-notebook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dschep%2Fexecutive-orders-notebook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dschep","download_url":"https://codeload.github.com/dschep/executive-orders-notebook/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242951172,"owners_count":20211572,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["data-visualization","jupyter","jupyter-notebook","trump"],"created_at":"2024-10-12T02:08:35.182Z","updated_at":"2025-12-16T06:08:02.606Z","avatar_url":"https://github.com/dschep.png","language":"Jupyter Notebook","readme":"\n# Executive Order plots Jupyter notebook\n\nI wanted to compare how many Executive Orders Trump is signing compared to recent previous presidents.\n\n\n```python\nfrom datetime import datetime\n\nimport requests\nfrom bs4 import BeautifulSoup\nimport matplotlib.pyplot as plt\nfrom matplotlib import style\n\nstyle.use('ggplot')\n```\n\n\n```python\nURL_TEMPLATE = 'http://www.presidency.ucsb.edu/executive_orders.php?Submit=DISPLAY\u0026year={year}'\ndef get_executive_orders(start_year=1826):\n    for year in range(start_year, datetime.now().year + 1):\n        resp = requests.get(URL_TEMPLATE.format(year=year))\n        soup = BeautifulSoup(resp.content, 'html.parser')\n        table = soup.form.next_sibling.next_sibling\n        for row in table.find_all('tr')[1:]:\n            columns = row.find_all('td')\n            try:\n                date = datetime.strptime(columns[1].text, '%B %d, %Y')\n            except ValueError:\n                # for some reason one of the dates is June 0 ¯\\_(ツ)_/¯\n                if columns[1].text == 'June 0, 1887':\n                    date = datetime(1887, 6, 1)\n                else:\n                    print('skipping unparsable date {}'.format(columns[1].text))\n                    continue\n            yield {\n                'president': columns[0].text,\n                'date': date,\n                'name': columns[2].text,\n                'link': columns[2].a['href'],\n            }\n```\n\nSimplify by only using presidents after 1937 when inaugurations are on Jan 20th and simplify even more to avoid issues with impeachment(Nixon) and assassinations(JFK) by skipping to 1977 (Jimmy Carter)\n\n\n```python\norders_by_president_by_day_of_presidency = {}\ninauguration_dates = {}\nfor order in get_executive_orders(1977):\n    if order['date'] \u003c datetime(1977, 1, 20):\n        continue\n    if order['president'] not in inauguration_dates:\n        inauguration_dates[order['president']] = order['date'].replace(day=20)\n    start_date = inauguration_dates[order['president']]\n    orders = orders_by_president_by_day_of_presidency.setdefault(order['president'], {})\n    order['day'] = int((order['date'] - start_date).total_seconds() / 60 / 60 / 24)\n    if order['day'] not in orders:\n        orders[order['day']] = 1\n    else:\n        orders[order['day']] += 1\n```\n\n\n```python\nfor president, orders in sorted(orders_by_president_by_day_of_presidency.items(),\n                                key=lambda x: inauguration_dates[x[0]]):\n    x = range(max(orders) + 1)\n    y = []\n    total = 0\n    for i in x:\n        total += orders.get(i, 0)\n        y.append(total)\n    plt.plot(x, y, label=president, drawstyle='steps-post')\n\nplt.legend()\nplt.title('Executive Orders over entire Term')\nplt.xlabel('days in office')\nplt.ylabel('number of executive orders')\nplt.show()\n```\n\n\n![png](README_files/README_5_0.png)\n\n\n\n```python\ndays = (datetime.now() - inauguration_dates['Donald J. Trump']).total_seconds() / 60 / 60 / 24\nmax_ = 0\nfor president, orders in sorted(orders_by_president_by_day_of_presidency.items(),\n                                key=lambda x: inauguration_dates[x[0]]):\n    if max(orders) \u003e max_:\n        max_ = max(orders)\n    x = range(max_ + 1)[:int(days)]\n    y = []\n    total = 0\n    for i in x:\n        total += orders.get(i, 0)\n        y.append(total)\n    plt.plot(x, y, label=president, drawstyle='steps-post')\n\nplt.legend()\nplt.title(\"Executive Orders compared to Trump's term so far\")\nplt.xlabel('days in office')\nplt.ylabel('number of executive orders')\nplt.show()\n```\n\n\n![png](README_files/README_6_0.png)\n\n\nAnd out of curiosity, how do those spikes at the ends of terms compare\n\n\n```python\nfor president, orders in sorted(orders_by_president_by_day_of_presidency.items(),\n                                key=lambda x: inauguration_dates[x[0]]):\n    if president == 'Donald J. Trump':\n        continue  # skip Trump, his term hasn't ended yet :'(\n    last_day = max(orders)\n    y = []\n    total = 0\n    for i in range(last_day - 180, last_day + 1):\n        total += orders.get(i, 0)\n        y.append(total)\n    plt.plot(range(181), y, label=president, drawstyle='steps-post')\n\nplt.legend()\nplt.title('Executive Orders in last month in Office')\nplt.xlabel('days in office')\nplt.ylabel('number of executive orders')\nplt.show()\n```\n\n\n![png](README_files/README_8_0.png)\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdschep%2Fexecutive-orders-notebook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdschep%2Fexecutive-orders-notebook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdschep%2Fexecutive-orders-notebook/lists"}