Question: The Data Set Information CTA - Ridership - L Station Entries - Daily Totals Transportation. Updated October 25, 2019. Data is provided by Chicago Transit
The Data Set Information
CTA - Ridership - L Station Entries - Daily Totals Transportation. Updated October 25, 2019. Data is provided by Chicago Transit Authority. Source: https://data.cityofchicago.org/Transportation/CTA-Ridership-L-Station-Entries-Daily-Totals/5neh-572f
The file is called CTA-Ridership-L-Station-Entries-Daily-Totals.csv. The data contained in the file, a sample given below, shows daily totals of ridership, by station entry, for each L station dating back to 2001. Dataset shows entries at all turnstiles, combined, for each station. The data columns are self- explanatory and can be read-off the first line in the data sample below. The abbreviated daytypes are as follows: W=Weekday, A=Saturday, U=Sunday/Holiday. The file size is 35.4 MB.
station_id,stationname,date,daytype,rides 40850,Library,10/09/2004,A,1057 40780,Central Park,06/18/2010,W,1154 41500,Montrose-Brown,10/30/2001,W,2116 40500,Washington/State,10/26/2006,W,0 41090,Monroe/State,07/07/2010,W,9431 40080,Sheridan,05/29/2009,W,5601 40350,UIC-Halsted,12/06/2008,A,2038 40390,Forest Park,10/23/2015,W,3854 41150,Kedzie-Midway,05/15/2003,W,2840 40730,Washington/Wells,10/26/2013,A,1444 40570,California/Milwaukee,10/26/2008,U,1527 40150,Pulaski-Cermak,08/18/2016,W,1115
Assignments
Assignment 1.[15 Points] Write a Python function that takes a file name, as a string s, on input and, when called with s = CTA-Ridership-L-Station-Entries-Daily-Totals.csv reads in all data contained in the file. You are strongly encouraged to use the Pandas module for this task (as illustrated in lecture notes) but you are free to write your own CSV file reader, if you want. The function you write to complete Assignment 1 will be used to complete the subsequent assignments below.
Assignment 2.[15 Points] Write a function that prints to screen the average number of rides, for all months, for the UIC-Halsted (station id = 40350) train station. Use the solution from Assignment 1 to access the data.
The output of your function must have the format
January : average number of rides as a float February: average number of rides as a float .
February: average number of rides as a float .
December: average number of rides as a float
Assignment 3.[20 Points] Write a function that computes the average number of rides, for all days of the week, for the UIC-Halsted (station id = 40350) train station. Use the solution from Assignment 1 to access the data. Assign the value of 1 for Monday, 2 for Tuesday, ... , and 7 for Sunday. Using the polynomial curve fitting capabilities of NumPy, fit the data with a polynomial of degree 6.
Using the degree 6 polynomial fit
predict the number of rides on a Wednesday for the UIC-Halsted train station estimate which day of the week is the UIC-Halsted trains station most busy estimate which day of the week is the UIC-Halsted trains station least busy
You may use the following Python function to get the name of the weekday, given a date.
def getWeekday(year, month, day): """
input: integers year, month, day output: name of the weekday on that date as a string """ import datetime import calendar
date = datetime.date(year, month, day) return calendar.day_name[date.weekday()]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
