Government, History

Celebrating the anomaly of Jimmy Carter

Former President Jimmy Carter recently turned 100 years old. Any American who becomes president has by definition lived an exceptional life, but Carter stands out among peers. While six presidents have lived into their 90s, including Carter, he’s now the first to conquer the century mark.

Beyond that, Carter has spent nearly 44 years in retirement from the highest office—a full decade longer than second place. That’s longer than Teddy Roosevelt and JFK had been alive at the time they were inaugurated (42.9 and 43.6 years respectively). Let’s take a look at presidential time in retirement.

Carter with his fiancée (left) and mother (right) at his US Naval Academy graduation, June 1946.

1. Prepare the data.

The dataset I use will be linked at the bottom of this post. It lists each president’s birth, death, inauguration date, and final day in office. We’ll use it to calculate time in retirement and then plot the results.

First, load the data into a pandas DataFrame.

import pandas as pd

df = pd.read_csv("potus_data.csv", parse_dates=['birth', 'death', 'inauguration', 'leave_office'])

Many former presidents are still alive so we shouldn’t use a “death” column. We’ll be comparing time in retirement so let’s call the value a “high score.” And for those former presidents still here and celebrating with us, we can substitute today’s date.

df.loc[:, 'high_score'] = df['death'].fillna(pd.Timestamp("November 1, 2024"))

To calculate time in retirement, we can apply a lambda function. As a disclaimer, this approach isn’t technically 100% correct because there was no Leap Day in 1800 or 1900. The bottom line when dealing with units of years is that there is no perfect approach—only a selection of incorrect methods to choose from, depending on your patience and need for precision. Dividing by 365.25 is usually good enough for me.

df.loc[:, 'years_in_retirement'] = df.apply(lambda row: (row['high_score'] - row['leave_office']).days / 365.25, axis=1)

Sort the DataFrame by our new column to showcase Carter. Reset the index because we’ll use it in a moment to plot the data. Exclude zero values in the interest of good taste.

df = df[df['years_in_retirement'] > 0]

df = df.sort_values("years_in_retirement", ascending=False).reset_index(drop=True)

Take a look at the data before we move on to Matplotlib. It’s fair to say that Carter has fought death to a draw.

                    name leave_office high_score  years_in_retirement
0           Jimmy Carter   1981-01-20 2024-10-29            43.772758
1         Herbert Hoover   1933-03-04 1964-10-20            31.630390
2            Gerald Ford   1977-01-20 2006-12-26            29.930185
3      George H. W. Bush   1993-01-20 2018-11-30            25.859001
4             John Adams   1801-03-04 1826-07-04            25.333333
5           Bill Clinton   2001-01-20 2024-10-29            23.772758
6       Martin Van Buren   1841-03-04 1862-07-24            21.388090
7       Millard Fillmore   1853-03-04 1874-03-08            21.010267
8        Harry S. Truman   1953-01-20 1972-12-26            19.931554
9          Richard Nixon   1974-08-09 1994-04-22            19.701574
10         James Madison   1817-03-04 1836-06-28            19.318275
11     John Quincy Adams   1829-03-04 1848-02-23            18.973306
12      Thomas Jefferson   1809-03-04 1826-07-04            17.333333
13   William Howard Taft   1913-03-04 1930-03-08            17.010267
14            John Tyler   1845-03-04 1862-01-18            16.876112
15        George W. Bush   2009-01-20 2024-10-29            15.772758
16         Ronald Reagan   1989-01-20 2004-06-05            15.373032
17       Franklin Pierce   1857-03-04 1869-10-08            12.596851
18   Rutherford B. Hayes   1881-03-04 1893-01-17            11.874059
19      Grover Cleveland   1897-03-04 1908-06-24            11.304586
20    Theodore Roosevelt   1909-03-04 1919-01-06             9.842574
21      Ulysses S. Grant   1877-03-04 1885-07-23             8.386037
22        Andrew Jackson   1837-03-04 1845-06-08             8.262834
23  Dwight D. Eisenhower   1961-01-20 1969-03-28             8.183436
24     Benjamin Harrison   1893-03-04 1901-03-13             8.021903
25          Barack Obama   2017-01-20 2024-10-29             7.772758
26        James Buchanan   1861-03-04 1868-06-01             7.244353
27        Andrew Johnson   1869-03-04 1875-07-31             6.406571
28          James Monroe   1825-03-04 1831-07-04             6.332649
29     Lyndon B. Johnson   1969-01-20 1973-01-22             4.005476
30       Calvin Coolidge   1929-03-04 1933-01-05             3.841205
31          Donald Trump   2021-01-20 2024-10-29             3.772758
32        Woodrow Wilson   1921-03-04 1924-02-03             2.918549
33     George Washington   1797-03-04 1799-12-14             2.778919
34     Chester A. Arthur   1885-03-04 1886-11-18             1.708419
35         James K. Polk   1849-03-04 1849-06-15             0.281999
Former President Hoover meeting with President Kennedy, April 1961.

2. Plot the data.

We’re visualizing one-dimensional data so the obvious choice is a bar chart. But with (long) names along the independent axis, a horizontal bar chart will be easier to read.

The code is straightforward. We use the DataFrame’s index as the independent variable and swap in president names for yticklabels. I chose to give Carter’s bar extra color to draw the viewer’s attention.

import matplotlib.pyplot as plt

plt.style.use("wollen_gray.mplstyle")
fig, ax = plt.subplots(figsize=(8, 12))

ax.barh(df.index, df['years_in_retirement'],
        color=["#0270CF" if name == "Jimmy Carter" else "#888" for name in df['name']],
        height=0.6)

ax.set_yticks(df.index, labels=df['name'])
ax.set_ylim(-0.8, 35.8)

ax.set_xticks(range(0, 50, 5))

ax.set_title("US Presidents  •  Years in Retirement  •  Through November 1, 2024")

plt.savefig("potus_retirement.png", dpi=150)

3. The output.

Clearly Carter knows something the rest of us do not! From Plains, Georgia to the White House to eradicating the Guinea worm and housing families who need a hand, congratulations to him on a life well lived.


Download the data.

Full code:

import pandas as pd
import matplotlib.pyplot as plt


df = pd.read_csv("potus_data.csv", parse_dates=['birth', 'death', 'inauguration', 'leave_office'])

df.loc[:, 'high_score'] = df['death'].fillna(pd.Timestamp("November 1, 2024"))

df.loc[:, 'years_in_retirement'] = df.apply(lambda row: (row['high_score'] - row['leave_office']).days / 365.25, axis=1)

df = df[df['years_in_retirement'] > 0]

df = df.sort_values("years_in_retirement", ascending=False).reset_index(drop=True)

print(df[['name', 'leave_office', 'high_score', 'years_in_retirement']])

plt.style.use("wollen_gray.mplstyle")
fig, ax = plt.subplots(figsize=(8, 12))

ax.barh(df.index, df['years_in_retirement'],
        color=["#0270CF" if name == "Jimmy Carter" else "#888" for name in df['name']],
        height=0.6)

ax.set_yticks(df.index, labels=df['name'])
ax.set_ylim(-0.8, 35.8)

ax.set_xticks(range(0, 50, 5))

ax.set_title("US Presidents  •  Years in Retirement  •  Through November 1, 2024")

plt.savefig("potus_retirement.png", dpi=150)