Using Python to Make Pulling Census Data Easy

I pull a lot of census data at my day job.  This especially applies to the American Community Survey (ACS).  This survey replaced the decennial census “long form” and provides a staggering amount of data.  We use this data to create community profiles.  So every December when the Census Bureau releases the 5-year estimates I spend a good deal of time downloading data.

But today I think I have a way to significantly cut this time down.  I brushed off my python skills and wrote a little script to pull the data from the Census API.  As you might recall I use both Python and R in my work using the best tool for the job.  This time I used Python to get the job done.

This Python script is important to me as it was my first real foray with Pandas.  My previous experience with R’s data frames made the transition pretty smooth.  I also used Spyder as my development environment.  While it is not as awesome as RStudio, it wasn’t bad.

As always, this Python script is posted to my GitHub repository.


8 thoughts on “Using Python to Make Pulling Census Data Easy

  1. Mike says:

    Hey Mike,

    I just wanted to say thanks for posting your script on GitHub. I used it as a starting point to help automate some of my work mapping ACS data relating to underserved populations and Title 6 at an MPO. Thanks again!


  2. rutni says:

    Hello. I got this error:
    UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0x93 in position 15: invalid start byte

    • Mike Silva says:

      Try changing the read_csv() command. Adding something like encoding = “ISO-8859-1” should resolve the error.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s