> ## Content Index
> Fetch the complete content index at: https://www.bambooweekly.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# Bamboo Weekly #50: Red Sea shipping
- URL: https://www.bambooweekly.com/bw-50-red-sea-shipping/
- Published: 2024-01-24T17:42:53.000Z
- Updated: 2026-08-06T10:45:33.000Z
- Description: Get better at: CSV, multiple files, filtering, regular expressions, dates and times, window functions
- Author: Reuven M. Lerner
- Tags: csv, multiple-files, filtering, regular-expressions, datetime, window-functions

We're now more than three months into the war between Israel and Hamas. While I have many thoughts on the war, this issue focuses on an unexpected war-related development, specifically, the Houthi rebels in Yemen expressing their solidarity with Hamas by attacking ships in the Red Sea. (They claim to be attacking ships that are owned by or trading with Israel, but that turns out not to be the case.)

Shipping companies are now paying more in insurance to go through the Red Sea, or they're rerouting their ships to go around the Cape of Good Hope in South Africa. Either way, it would seem that these Yemeni rebels' actions are responsible for a rise in inflation.

NPR's Planet Money reported on this topic earlier this month ([https://www.npr.org/2024/01/02/1197959330/red-sea-tensions-global-shipping](https://www.npr.org/2024/01/02/1197959330/red-sea-tensions-global-shipping?ref=bambooweekly.com)), and Marketplace had a story on it as well ([https://www.marketplace.org/2024/01/17/red-sea-attacks-houth-rebels-shipping-rates/](https://www.marketplace.org/2024/01/17/red-sea-attacks-houth-rebels-shipping-rates/?ref=bambooweekly.com)).

This week, we'll look at how many ships normally travel through the Red Sea and Suez Canal, and how many appear to be rerouted.

### Data and seven questions

This week's data comes from PortWatch ([https://portwatch.imf.org/](https://portwatch.imf.org/?ref=bambooweekly.com)), a joint project between the International Monetary Fund and the University of Oxford that was launched in November. They aim to track ships and ports around the world, and to give us insights into what's happening on those fronts.

We'll look at three related data sets, all describing the traffic of cargo ships and oil tankers:

1. The number of ships passing through Bab el Mandeb, the "Strait of Tears" at the entrance to the Red Sea
2. The number of ships passing through the Suez Canal
3. The number of ships going past the Cape of Good Hope, in South Africa.

All three of these can be downloaded from the PortWatch page, "Trade disruptions in the Red Sea" ([https://portwatch.imf.org/pages/573013af3b6545deaeb50ed1cbaf9444](https://portwatch.imf.org/pages/573013af3b6545deaeb50ed1cbaf9444?ref=bambooweekly.com)). Click on the "export data" link next to each graph, and choose the CSV export. (The Excel export produces an HTML file, rather than an actual Excel file, despite the ".xls" extension.)

The learning goals for this week's questions include:

- Creating a single data frame from several files
- Working with date/time values, including resampling
- Window functions
- Plotting

Here are my seven tasks and questions for you this week. I'll be back tomorrow with my detailed solutions, including the Jupyter notebook I used to solve the problems myself:

- Create a dictionary of data frames, in which the keys are short (3-5 letter) nickname for the data source, and the values are data frames, one for each of the three CSV files. In each data frame, the original "DateTime" column should be the index, and parsed as a "datetime" dtype. Keep only the "Number of Cargo Ships" and "Number of Tanker Ships" columns, renamed to something shorter.
- Join these three data frames together into a single data frame with six columns (two from each of the original data frames).
- What is the mean number of cargo ships we see in each location each month? Create a line plot graphing it. Do we see any indication of the conflict's influence over the last few months?
- Create a line plot showing the number of oil tankers in each location during each week, starting the first week of September 2023\. Did the problems start immediately after the Hamas attack of October 7th?
- When was the number of ships (of either type) going through the Suez Canal at a minimum?
- Some of those low numbers are from March 2021, when a large tanker (the Evergreen) got stuck in the Suez Canal and blocked traffic. Show, for both the Suez Canal and Bab el Mandeb, the smallest and largest number of ships for each rolling 3-day period from March 15, 2021 through April 1st.
- Calculate, for each 3-month period (quarter) in our data set, the mean number of ships of each type, in each location. Now calculate the percentage change in that mean for each quarter. Where is the greatest increase for each location? Where is the greatest decrease?

I’ll be back tomorrow with my solutions.

Reuven