[Administrative note: We'll have Pandas office hours tomorrow! I'll send Zoom info in a few hours. Office hours are for paid BW subscribers, but also for LernerPython+data subscribers, who can get the Zoom info on the (new!) personal calendar at https://lernerpython.com/my-account/my-calendar/. That personal calendar also has dozens of archived members-only lectures on a variety of topics.]
We all need to live somewhere -- and for many of us, that means eventually buying a home. But houses are expensive, and for many people, they have recently become even more expensive.
I heard an interview about the high cost of US housing on yesterday's Marketplace (https://www.marketplace.org/story/2026/07/28/as-mortgage-rates-stay-high-this-lender-is-seeing-buyers-accept-the-new-normal#as-mortgage-rates-stay-high-this-lender-is-seeing-buyers-accept-the-new-normal) and in a recent episode of Slate Money (https://slate.com/podcasts/slate-money/2026/07/business-your-electricity-bill-is-growing-with-a-i).
Both shows talked about the fact that there is just too little housing stock in the US. Reduced supply and increased demand will, pretty clearly, lead to higher prices.
But inflation has kept interest rates high, and those rates influence mortgage rates. Which means that if you need a mortgage to buy a home today, you're looking not only at a higher price, but at a costlier monthly payment for that same price.
I thought that it might be interesting to look at the American housing market. But then I remembered hearing that other countries were also faced with expensive housing, and thought that it might be interesting to compare the situation across the world, and see where housing prices have risen most dramatically, and where they haven't. We'll concentrate on the housing prices themselves, rather than the cost of a mortgage, partly to simplify things, and partly because every country has a different approach to mortgage lending.
Data and six questions
This week, we'll look at historical housing-price data from the Bank for International Settlements (https://bis.org), an international organization that coordinates communication and policy among central banks. They collect and publish a wide variety of data from countries around the world, including residential property prices (https://data.bis.org/topics/RPP/data).
You can export the data from the BIS site, but we want more rows than it would actually allow us to export. For that reason, I suggest just retrieving the CSV file directly from the site:
https://stats.bis.org/api/v2/data/dataflow/BIS/WS_SPP/1.0/?format=csv&labels=both
Notice several parts of this request:
- I asked for
WS_SPP, the selected data, which is more than enough. Another option is to retrieveWS_DPP, with the detailed data. - I asked for the file in CSV format
- I asked for
labels=both, so that I would get both the shortened forms of some labels and columns, and also the long forms. This makes it far easier to understand some of the data. For example, it ensures that we'll get the name of each country, and not just the two-letter abbreviation.
The analysis comes in four different flavors, in two different axes:
UNIT_MEASUREcan be either 628 (relative to housing prices in 2010, which is defined to be 100) or 771 (percentage change from the same quarter in the previous year). If you're in 2011 and prices are twice what they were the year before, then it'll be a 628 measurement of 200, but a 771 measurement of 100 (percent). In general the 628 index is cumulative since 2010, while 771 covers only the most recent year — so outside of 2011 the two numbers won't correspond like this.VALUEdetermines whether inflation has been stripped out. N is "nominal", the raw price movement in local currency. R is "real", the same movement with consumer price inflation stripped out. If you're in 2011 and the 628 price is 200 for nominal, then that means what used to cost 100 now costs 200. But if there was 100 percent inflation (!), then the real price would actually be the same, and it would show 100 for real.
Paid subscribers, both to Bamboo Weekly and to my LernerPython+data membership program (https://LernerPython.com) get all of the questions and answers, as well as downloadable data files, downloadable versions of my notebooks, one-click access to my notebooks, and invitations to monthly office hours.
Learning goals for this week include cleaning data, dates and times, grouping, plotting with Plotly, regular expressions, and built-in window functions.
Here are my six questions for this week. I'll be back tomorrow with my solutions and explanations:
- Download the data from BIS, and turn it into a Pandas data frame. Create a
datecolumn (with adatetimedtype) from theTIME_PERIODcolumn, choosing the first day of the first month in the specified quarter. (So Q1 will be January 1st, Q2 will be April 1st, etc.) This means that you'll have four distinct dates for each year, one per quarter. - Create a line plot showing, over time, the percentage change in nominal housing costs in emerging economies vs. advanced economies. Do we see prices changing more dramatically in one rather than the other? Repeat this for real values; do things change? (Note that aggregates start from about 2008, as opposed to countries, which start earlier.)