TDM 10200: Project 12 — Spring 2024
*Motivation: Learning classes in Python
Scope: Object Oriented Python
Scope: Python, python class, pandas
Reading and Resources
Dataset
/anvil/projects/tdm/data/flights/2014.csv
You need to use 2 cores for your Jupyter Lab session for Project 11 this week. |
You can use |
Questions
Question 1 (2 points)
-
In the previous project, you created a class named
Flight
, which contains attributes for the flight number, origin airport ID, destination airport ID, departure time, arrival time, departure delay, and arrival delay. Now let us use this class as a base class. Create a new subclass calledScheduledFlight
. Add 2 more attributes to this new subclass:CRSDepTime
andCRSArrTime
. -
Add a method called
is_ontime()
to the class, which returns a boolean value that indicates if the flight departs on time and arrives on time.
Question 2 (2 points)
-
Create a DataFrame named
myDF
, to store data from the2014.csv
data set. It suffices to import (only) the columns listed below, and to (only) read in the first 100 rows. Although we provide thecolumns_to_read
, please make (and use) a dictionary ofcol_types
like we did in Question 1 of Project 10. -
Load the data from
myDF
into the ScheduledFlight class instances. (When you are finished, you should have a list of 100 ScheduledFlight instances.)
columns_to_read = [
'DepDelay', 'ArrDelay', 'Flight_Number_Reporting_Airline', 'Distance',
'CarrierDelay', 'WeatherDelay', 'CRSDepTime', 'CRSArrTime',
'DepTime', 'ArrTime', 'Origin',
'Dest', 'AirTime'
]
Question 3 (2 points)
-
Create an empty dictionary named
ontime_count
. Then use a for loop to assign values toontime_count
from the 100 ScheduledFlight objects. -
Calculate the total number of flights that were on time, for each destination airport.
Question 4 (2 points)
-
Add a method called
is_delayed()
to the class that indicates if the flight was delayed (either had a departure delay or an arrival delay). -
Calculate the total number of delayed flights, for each destination airport.
Question 5 (2 points)
-
Create a subclass of your own, with at least one method, and then use the dataset to get some meaningful information that uses this subclass.
Project 12 Assignment Checklist
-
Jupyter Lab notebook with your code, comments and output for the assignment
-
firstname-lastname-project12.ipynb
.
-
-
Python file with code and comments for the assignment
-
firstname-lastname-project12.py
-
-
Submit files through Gradescope
Please make sure to double check that your submission is complete, and contains all of your code and output before submitting. If you are on a spotty internet connection, it is recommended to download your submission after submitting it to make sure what you think you submitted, was what you actually submitted. In addition, please review our submission guidelines before submitting your project. |