The United States government is based on the idea of "checks and balances," meaning that no one branch of government – executive, legislative, or judicial – can do much on its own. Rather, each branch needs the support of at least one other branch in order to accomplish something. The classic case is of passing a law: Congress needs to pass it, then the president signs it, and then the courts (over time) uphold it as acceptable and constitutional.
But there is one area in which the president has basically unlimited authority, namely when it comes to pardons, which is granted to him alone. The president can pardon someone, or can grant them clemency, meaning that their sentence is reduced or eliminated.
Donald Trump has recently been in the news for his numerous pardons of questionable figures. For example, Binance head CZ was convicted of money laundering and working with terrorist groups. But Trump is now very pro-crypto, and Binance has partnered with the Trump family's crypto ventures, so he is now free.
Earlier this week, Trump pardoned the former president of Honduras, who was convicted of drug smuggling, to the tune of 400 tons of cocaine (https://www.nytimes.com/2025/12/03/nyregion/bove-trump-honduras-pardon.html?unlocked_article_code=1.508.zVbf.sfJ_aLYQd5iz&smid=url-share). This is at the same time as Trump threatens Venezuela over drug smuggling.
I thought it might be interesting to look at the history of pardons and clemency, and see if we can spot any trends. The data comes from the US Department of Justice's own numbers, at the page at https://www.justice.gov/pardon/clemency-statistics . Sadly, it doesn't yet include any information about Trump's current term. But it does include a fair number of other data points that we can use to examine pardons. Here's an article indicating that Biden gave more clemency than any other president, along with some definitions: https://www.pewresearch.org/short-reads/2025/02/07/biden-granted-more-acts-of-clemency-than-any-prior-president/
Data and five questions
As mentioned above, this week's data comes from the Department of Justice's page at https://www.justice.gov/pardon/clemency-statistics . It only contains data through the Biden administration, meaning that the numbers for the second Trump administration aren't yet available or included. Also, the data is in HTML tables on that page, rather than being downloadable. Which means that it's yet another Web-scraping week here at BW!
Learning goals for this week include: Web scraping, combining data frames, multi-indexes, grouping, and plotting.
Paid subscribers, including members of my LernerPython.com membership program, get the data files provided to them (except for this week, since retrieving them is part of the task), as well as all of the questions and answers each week, downloadable notebooks, and participation in monthly office hours.
Here are my five questions for this week. I'll be back tomorrow with solutions and full explanations:
- Retrieve data from the DOJ's page into a data frame for each president. Using a manually constructed list of presidents' names (as strings), create a single data frame whose two-level index contains the president's name and the year, and the data columns contain
either Petitions ReceivedorPetitions Granted. - For modern presidents, the
PandCcolumns are used for pardons and commutation. But for earlier presidents, thePardonsandCommutationcolumns are used instead. Add thePardonsandCommutationsnumbers forPetitions Grantedto the existingPandCcolumns, then remove thePardonsandCommutationcolumns.