Get startedGet started for free

Annual Change

1. American Community Survey: Annual Change

Welcome back! In this chapter we will explore the extensive social and economic characteristics reported annually in the American Community Survey. First, a bit of history!

2. Census History: Counts and Samples

The Decennial Census is an attempted full count of population that has been conducted every decade since 1790. Since 1970, the Census has also surveyed a sample of the population on a more extensive set of questions. From 1970 to 2000, this survey was part of the Decennial Census. 1/6 of households received the "Long Form" Questionnaire. Results were released as "Summary File 3". But Conducting the Census has become more expensive over time. Moreover, population data begins to become stale in between censuses The American Community Survey launched in 2005, providing annual updates of population characteristics. Improvements in sampling methodology have allowed the bureau to conduct the ACS with a much smaller sample than the Census Long Form, about 1.5% of the population annually.

3. B25045 - Tenure by Vehicles Available by Age

Requesting variables for the ACS works the same as for the Census. We're going to request all 19 variables from the ACS table B25045 - "Tenure by Vehicles Available by Age of Householder". The table has a hierarchical structure. The first variable is total occupied housing units. The total is broken into owner-occupied and renter-occupied units. These are broken into households with and without available vehicles. The final breakdown is into three age categories. This hierarchical structure is common to Census and ACS tables.

4. ACS Detailed Table Request - Setup

To request this table, begin by setting up the base URL components. Don't define a year variable yet. You'll see why in just a moment. In order to avoid typing 19 variable names, use a list comprehension. range(19) returns integers from 0 to 18. s-t-r(i+1) adds 1 to each element in the range and converts to string. The zfill function prepends zeroes to the specified length, 3 in this case. This gets added to the table name, and followed by "E" for estimate. This is what get_vars looks like when we're done.

5. ACS Detailed Table Request - Setup

This setup should be familiar from last chapter. The for-predicate "us:*"" introduces a new geography available for the ACS. It retrieves data for the United States as a whole.

6. Requesting Same Variables from Multiple Years

Since each year of ACS data is a different product, we use multiple requests. We use a loop to request the same variables for each year. Begin by creating an empty list, dfs, to use as a collector for the DataFrames. Begin the for loop. range(2011, 2018) will generate integers from 2011 to 2017. Inside the loop, build the base URL and execute the request. On the first iteration, data for 2011 is downloaded. Construct the DataFrame from the json response. The column names are taken from the header row, index 0 of r.json. The data is taken from all subsequent rows. Now add a column named "year", and set the value equal to the current value of the year variable. Finally, append this DataFrame to the collector. The loop now iterates these steps for years up to 2017. Outside of the loop, use pd.concat to concatenate all DataFrames in the collector, creating the final DataFrame us.

7. Requesting Same Variables from Multiple Years

This is the result. Notice that the DataFrame has a GEOID column named "us", all equal to 1. The column names are the original ACS variable names. In the exercises, you will use more user-friendly column names.

8. Let's Get Some Data!

In the exercises, you will request ACS data for multiple years. You will also calculate percentages, and graph change over time. Let's go!