Practicum 1: The "L"

Objectives:

  • Apply topics in section 1 to a real problem

Files Created: ctarides.py

Files Modified: None

The file Data/ctarail.csv contains a history of CTA "L" ridership from January 1, 2001 to December 31, 2012. The data looks like this:

station_id,stationname,date,daytype,rides
40010,Austin-Forest Park,01/01/2001,U,290
40020,Harlem-Lake,01/01/2001,U,633
40030,Pulaski-Lake,01/01/2001,U,483
40040,Quincy/Wells,01/01/2001,U,374
40050,Davis,01/01/2001,U,804

The "station_id" column contains a station ID code, "stationname" is the name of the station, "daytype" is one of "U" (Sunday/Holiday), "A" (Saturday), or "W" (Weekday), and the "rides" column contains the number of passengers that entered the turnstiles at that station.

Your task is as follows. In a file ctarides.py, define a function yearly_rides(filename, year) that simply tabulates the total number of rides for a given year. For example:

>>> # Compute the total rides for 2001
>>> yearly_rides('Data/ctarail.csv', 2001)
151739502
>>>

Use your function to write out the ride totals for each year from 2001 to 2012. Is there any kind of trend? Is ridership increasing or decreasing?

Links

[ Back | Next | Index ]