In addition to launching a trade war with just about everyone, including a bunch of penguins on an uninhabited island, Donald Trump has also been taking harsh (and quite possibly illegal) actions against non-citizens. Between stories of people's visas and green cards getting revoked, erroneously being sent to prisons in El Salvador, and being turned away at US airports, this has gotten many people jumpy about visiting the US.
Just last week, the Python Software Foundation announced that if people are uncomfortable traveling to the US from other countries, they can get a full refund on their conference ticket. We also saw an announcement that travel between the US and Canada (which Trump has threatened to annex) has dropped by 70 percent. And earlier this week, I heard that while American citizens continue to travel at the same rate as before, non-citizen travel has dropped dramatically.
This week, we'll thus be looking at air travel into the US over the last two years, at a number of US airports. We'll try to determine whether the number of non-US citizens has really dipped in recent weeks, and generally look at the distribution of passengers across various times and locations.
Tags!
Earlier this year, I started to tag each issue of Bamboo Weekly with the data-analysis tools and techniques mentioned in that issue, and also went back and tagged all back issues. Those tags have been displayed at the top of each issue for some time now; clicking on a tag lets you find other issues that test you on related topics. As of this week, I've also added a new "tags" page (https://bambooweekly.com/tags), which lists all of the tags, used across all BW back issues. If you're interested in practicing multi-indexes, or pivot tables, or DuckDB, this will help you find challenges on those topics.
My goal is to make Bamboo Weekly the best possible resource for people trying to improve their skills with data analysis and Pandas. (And of course, it's even better when it's a part of my full LernerPython+data membership program, which also includes courses, exercises, and members-only lectures.) If you have suggestions for how I can improve it further, please let me know; I'm always looking for ways to improve.
Data and six questions
This week, we'll look at data from the "airport wait time" site (https://awt.cbp.gov/) run by US Customs and Border Protection, part of the Department of Homeland Security. I downloaded Excel data from April 1, 2023 through April 7, 2025, for the following airports:
- Los Angeles International, Tom Bradley terminal
- Chicago O'Hare, terminal 5
- Atlanta airport
- Dallas / Fort Worth
- Newark Liberty airport
- San Francisco airport
Note that in two cases, I limited my search to only one terminal. This is because the site took a long time to generate those reports, and I grew tired of waiting. That's also why I limited my search to the last two years; for some airports, generating three years of data extended the wait time greatly.
Learning goals this week include working with multiple files, pivot tables, grouping, dates and times, filtering, and plotting.
Paid subscribers can download all of the data files from the bottom of this message.
I'll be back tomorrow with my solutions and explanations.
Meanwhile, here are the six tasks and questions:
- Download the data for the six airports, and combine them into a single data frame. Turn the "Flight Date" and "HourRange" columns into a single
datetime
column (using the first time in "HourRange"). Set the index to combine the "IATA" column (i.e., the airport name) and the "datetime" column. - Create a line graph showing, on a monthly basis, how many non-US passengers entered the US at each airport in this data set. Do we see any recent downturn?