The US election campaign ends in another two weeks, and one of the biggest issues among the electorate is the cost of housing. The problem with housing, from a variety of articles I've read, stems from too little supply. But of course, it's not quite that simple; an episode of NPR's Planet Money from August (https://www.npr.org/2024/08/30/1197961522/minneapolis-minnesota-housing-2040-tim-walz) describes how Minneapolis, Minnesota worked to incentivize the construction and renovation of homes, only to find that solving these problems can be challenging, even with the best of intentions.
This week, I thus decided to look through data on new housing construction in the United States. We'll be able to see how many homes are being constructed, where that construction is taking place, and what kinds of homes are being built. Along the way, of course, we'll have a chance to work with a variety of Pandas features.
Data and seven questions
This week's data comes from the US Census Bureau, whose "survey of construction" looks at new (not renovated or resold) homes. They offer a variety of data sets, all from this page:
https://www.census.gov/construction/nrc/data/series.html
We will look at only two of these data sets:
- Housing units started, https://www.census.gov/construction/nrc/xls/starts_cust.xlsx
- Housing units completed, https://www.census.gov/construction/nrc/xls/comps_cust.xlsx
This week, I have seven tasks and questions about this data. The learning goals include working with Excel files, joins, string manipulation, time series, multi-indexes, and plotting.
I'll be back tomorrow with my full solutions and explanations, including the Jupyter notebook I used to solve these problems.
- Create two data frames, one from each of the two Excel files references above, on the "Annual" tab in both files. The columns should be a two-level multi-index. Values labeled
(NA)should be turned intoNaN. Ignore the header and footer information. The index (rows) should contain the year from the first column. - Create a line plot showing total housing starts and completions in the overall United States. Show starts with a dashed blue line, and completed houses with a solid red line. When did the most recent big changes in the housing market take place?
- Create a line plot showing total housing starts in the US as well as each region. Do the regions all appear to move in sync? Where has most housing construction taken place in the last few decades?
- Find, for each decade, the number of total housing starts in the overall US. How do housing starts in the most recent years compare with preceding decades? The US population is now about 330m people, and was 203m in 1970; how might this affect the supply and demand for housing?
- Find, for each decade, the percentage of 1-unit housing starts (of the total) in the overall US. Does the percentage of single-family units appear to be increasing or decreasing over time? Show it in a line plot.
- In which year did we see the most and least 1-unit homes completed, in the US overall and in each of the tracked regions?
- Calculate the correlation between the total number of housing starts in each of the four regions of the United States. Which regions, if any, are highly correlated with one another?
Until tomorrow,
Reuven