- Read in the flights dataset, and output the first five rows:
>>> flights = pd.read_csv('data/flights.csv')>>> flights.head()
- Before we start plotting, let's calculate the number of diverted, cancelled, delayed, and ontime flights. We already have binary columns for diverted and cancelled. Flights are considered delayed whenever they arrive 15 minutes or more later than scheduled. Let's create two new binary columns to track delayed and on-time arrivals:
>>> flights['DELAYED'] = flights['ARR_DELAY'].ge(15).astype(int)>>> cols = ['DIVERTED', 'CANCELLED', 'DELAYED']>>> flights['ON_TIME'] = 1 - flights[cols].any(axis=1)>>> ...