Skip to content
3 min read csv

BW #52: Border encounters

Get better at: CSV, dates and times, plotting, grouping, multi-indexes, and stack-unstack.

BW #52: Border encounters

[Administrative note: Office hours for paid Bamboo Weekly subscribers will take place on Sunday. Come with any and all questions about Pandas! I’ll send a note with the Zoom link in the coming days.]

The Biden administration has committed to providing military aid to Ukraine, Israel, and Taiwan. Of course, it can't do so unless Congress approves such spending; for the most part, Democrats want to approve this spending, while Republicans don't.

A number of senators and representatives put together a compromise bill that would give Democrats foreign military aid, and Republicans money to secure the border further. However, this bill died over the last few days, thanks in no small part to Donald Trump, who told Republicans in Congress to oppose it. Biden has, shrewdly and correctly, already started to point out the hypocrisy of Republicans claiming to want to strengthen the border, but then failing to approve funding to do so when given the chance. A New York Times articles describing the situation is here: https://www.nytimes.com/2024/02/06/us/politics/border-republicans-ukraine-bill.html?unlocked_article_code=1.Tk0.xjzW.OJCxWbtkBliH&bgrp=c&smid=url-share

How many people are really crossing into the US? Where are these people from? And what changes have we seen over time? This week, we’ll examine this data, digging into a topic that has been at the top of the headlines.

Data and nine questions

Borders in the United States are regulated by the Department of Homeland Security's Customs and Border Protection (CBP). They describe "border encounters" as events when their agents come across a non-citizen who isn't allowed to be in the US. There are three different possible results of an encounter:

Our data is a CSV file provided by CBP describing border encounters starting in fiscal year 2021. The main page for downloading the data is at

https://www.cbp.gov/document/stats/nationwide-encounters

The file that we'll be examining shows information from fiscal year 2021 through fiscal year 2024, ending in December of FY 2024:

https://www.cbp.gov/sites/default/files/assets/documents/2024-Jan/nationwide-encounters-fy21-fy24-dec-aor.csv

You can get a complete data dictionary from:

/content/files/sites/default/files/assets/documents/2023-Sep/nationwide-encounters-data-dictionary.pdf

Note that you might need to go to the main page in order to download these documents; at least some of the time, I was unable to retrieve them via a direct link.

This week's learning goals include working with dates (including turning fiscal years into calendar years), grouping, resampling, window functions, and plotting.

Here are my 9 tasks annd questions for you. I’ll be back tomorrow with my complete solutions and Jupyter notebook.