Philadelphia City Council, programming

Philadelphia City Council: Pie charts & Stacked bar charts (10/12)

Next I wanted to be able to visualize the racial, party, and gender makeup of City Council in any given year. I had an html GET request to let the user select a year. It was embedded in a try/except block and an if/else conditional block. Since it’s possible for a user to enter a query in the url directly, I wanted a safeguard against query terms that are not integers and against integers that are outside the range of my data. Continue reading

Philadelphia City Council, programming

Philadelphia City Council: d3 visualizations (9/12)

I’ve come across many javascript libraries used to make data visualizations like pie charts, bar charts, timelines, etc. The easier they are to use, the less customizable they are. In a very early version of my city council project I used highcharts. This produced some great charts but I wanted to be able to customize them more. Enter d3. Continue reading

Philadelphia City Council, programming

Philadelphia City Council: Unique councilmembers (8/12)

Philadelphia has a reputation for having low turnover among city councilmembers. The city has loosely accurately rosters of each year’s cohort going back to the 1950’s. Election data is maintained only from 1979 on, representing the cohort that started in January 1980, which included newly elected members and re-elected incumbents. So I decided to focus just from 1980 on to ask the question, “How many unique councilmembers have served your district since 1980?” Anti-clickbait: The answer will not astound you. Continue reading

Philadelphia City Council, programming

Philadelphia City Council: Django’s admin interface (5/12)

Now that I set up my modules & populated my database, I moved on the using Django’s built-in admin interface to manage my project. In older versions of Django, admin users were created when the database was set up, using the python manage.py syncdb command. The newest version of Django decouples setting up the database from setting up users. To create a superuser, I typed:

(citycouncil)$ python manage.py createsuperuser

Continue reading

Philadelphia City Council, programming

Philadelphia City Council: Populating the database (4/12)

Now that the database was set up, I wanted to populate it with my data which I was temporarily storing in a couple of csv files.

Django has an API to get you do this but I decided to do this straight from the sqlite shell. I used the sqlite import function to import data into my tables from csv files. It was a bit finicky but I worked it out.

Continue reading