In [1]:
import pandas as pd # library for interacting with data
import matplotlib.pyplot as plt # library for plots and charts
from datetime import datetime, timedelta # library to help with time
In [2]:
inaugurations = { # list of inauguration dates and parties
    "Harry S. Truman": ("4/12/1945", "D"),
    "Dwight D. Eisenhower": ("1/20/1953", "R"),
    "John F. Kennedy": ("1/20/1961", "D"),
    "Lyndon B. Johnson": ("11/22/1963", "D"),
    "Richard Nixon": ("1/20/1969", "R"),
    "Gerald R. Ford": ("8/9/1974", "R"),
    "Jimmy Carter": ("1/20/1977", "D"),
    "Ronald Reagan": ("1/20/1981", "R"),
    "George H.W. Bush": ("1/20/1989", "R"),
    "William J. Clinton": ("1/20/1993", "D"),
    "George W. Bush": ("1/20/2001", "R"),
    "Barack Obama": ("1/20/2009", "D"),
    "Donald J. Trump_1": ("1/20/2017", "R"),
    "Joseph R. Biden, Jr.": ("1/20/2021", "D"),
    "Donald J. Trump_2": ("1/20/2025", "R")
}
In [3]:
df = pd.read_csv("executive_orders.csv") # open data
df['publication_date'] = pd.to_datetime(df['publication_date']) # clean date column
In [4]:
order_counts = [] # list to store counts

for president, (inauguration_date, party) in inaugurations.items(): # iterate through each president, date, and party
    start_date = datetime.strptime(inauguration_date, "%m/%d/%Y") # extract start date
    end_date = start_date + timedelta(days=100) # calculate end date
    
    filtered_df = df[ # create filtered dataframe
        (df['president'] == president) &  # filter df to only have president and dates within range
        (df['publication_date'] >= start_date) & 
        (df['publication_date'] <= end_date)
    ]
    
    executive_orders_count = len(filtered_df) # count the orders
    order_counts.append({ # append results
        'president': president, 
        'executive_orders_count': executive_orders_count, 
        'party': party
    })

order_counts = pd.DataFrame(order_counts) # convert results to dataframe
In [5]:
party_colors = {'D': 'blue', 'R': 'red'} # map parties to colors
order_counts['color'] = order_counts['party'].map(party_colors)

# create graph
plt.figure(figsize=(14, 7)) # set size
plt.bar( # set type and features
    order_counts['president'], 
    order_counts['executive_orders_count'], 
    color=order_counts['color'], 
    edgecolor='gray'
)

# set legend
party_labels = {'D': 'Democratic', 'R': 'Republican'} 
handles = [plt.Rectangle((0, 0), 1, 1, color=color) for color in party_colors.values()]
labels = [party_labels[party] for party in party_colors]

plt.title('Number of Executive Orders Executed Within 100 Days of Inauguration', fontsize=16, fontweight='bold')
plt.xlabel('President', fontsize=14)
plt.ylabel('Number of Executive Orders', fontsize=14)
plt.xticks(rotation=45, ha="right", fontsize=12)
plt.grid(True, axis='y', linestyle='--', linewidth=1)
plt.text(
    0, -0.4, 'Data as of April 29th, 2025',
    ha='left', va='center', fontsize=12, color='gray',
    fontweight='bold', transform=plt.gca().transAxes
)

plt.legend(handles, labels, title="Party", bbox_to_anchor=(1.05, 1), loc='upper left', fontsize=12)
plt.tight_layout()
plt.show()
No description has been provided for this image