Python Census Explorer: v1.0 is now Online!

A few weeks ago I wrote about my desire to build a “Census Explorer”-type app in Python. My thinking was not that the world needs yet another website to browse Census data. But rather (a) I was at a point in my “Data Science with Python” journey where it made sense to take on a side project, (b) this is a domain that I have some experience with and (c) the data is both interesting and free. Today I’m happy announce that version 1.0 of the app is now online and looks like this:

The app is quite simple. It gives you two choices: “select a state”, and “select a demographic statistic”. It then fetches the county-level data for that state and demographic and displays it as both a table and choropleth map. Since many of my readers are interested in learning how to develop websites like this, the app also includes a link to the github repo that contains the code.

Learning Goals

One thing that shocked me was how easy it was to create this app: Most of the work was done in a single day. That being said, that day came after going through the entire “30 Days of Streamlit” challenge and watching the entire censusdis tutorial video. As well as months of learning both basic Python and Pandas. So perhaps I’m underestimating how much work was involved!

My primary goal with the app goal was to break outside the constraints of coursework, and encounter the types of problems one finds on a “real” project. In that sense the project delivered in spades. Most of these problems I was able to solve on my own. But one required me to post on StackOverflow. A big thanks to Ramnath Vaidyanathan for the prompt answer!

Perhaps my biggest joy in the project was finally using Pandas to solve a real-world problem. For example, the names of all the counties comes back from censusdis as strings like “San Francisco County, California”. I wanted to drop the “, California” since it seemed redundant. I was quite happy when I accomplished this with the following code:

# "San Francisco, California" -> "San Francisco"
df['NAME'] = df['NAME'].apply(lambda x: x.split(',')[0])

Bamboo Weekly gives me regular practice with problems like this. I was glad the practice finally “paid off” when I needed it – a month ago I would not have been able to do this!

What’s Next?

This project has been both enjoyable and useful for me, and I see a few different ways to make it better. Stay tuned – I hope to take it in an interesting direction in the coming months!