Question: import pandas as p d import numpy as n p def monthly _ airport _ delays ( flights _ df ) : flights _ df

import pandas as pd
import numpy as np
def monthly_airport_delays(flights_df):
flights_df [ 'MONTH']=pd.to_datetime(flights_df ['SCHEDULED_DEPARTURE']).dt.strftime('%B')
flights_df ['DELAYED']= np.where(flights_df ['DEPARTURE_DELAY']>0,1,0)
monthly_delays=flights_df.groupby (['ORIGIN_AIRPORT', 'MONTH'])['DELAYED'].mean().reset_index()
monthly_delays_pivot = monthly_delays.pivot (index='MONTH', columns=' ORIGIN_AIRPORT', values='DELAYED')
return monthly_delays_pivot
monthly_airport_delays_df = monthly_airport_delays(flights_df_raw.copy())
print(monthly_airport_delays_df)
ORIGIN_AIRPORT
ATL
BOS
BWI
CLT
DEN
DFW
MONTH
January
0.374373,0.362486,0.486367,0.369094
0.455433,0.402733
ORIGIN_AIRPORT
DTW
EWR
IAH
JFK
LAS
LAX 1
MONTH
January
0.333843,0.439443,0.418491
0.376619
0.428222
0.420983
ORIGIN_AIRPORT
LGA
MCO
MSP
ORD
PHX
SEA
MONTH
January
0.365594,0.397218,0.314199,0.425718,0.408405,0.368633
ORIGIN_AIRPORT
SF0
SLC
MONTH
January
0.396972
0.281936
monthly_airport_delays_df = monthly_airport_delays(flights_df_raw.copy())
AssertionError: the shape of the dataframe supplied is incorrect expecting (11,5)
 import pandas as pd import numpy as np def monthly_airport_delays(flights_df): flights_df

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!