import numpy as np import matplotlib.pyplot as plt import pandas as pd
df=pd.read_csv('airlines.csv') df.columns
df2=df.pivot(index='Airport.Code', columns='Time.Label',values='Statistics.# of Delays.Weather')
column = df2['2008/05'] df.head(2)
Airport.Code | Airport.Name | Time.Label | Time.Month | Time.Month Name | Time.Year | Statistics.# of Delays.Carrier | Statistics.# of Delays.Late Aircraft | Statistics.# of Delays.National Aviation System | Statistics.# of Delays.Security | ... | Statistics.Flights.Delayed | Statistics.Flights.Diverted | Statistics.Flights.On Time | Statistics.Flights.Total | Statistics.Minutes Delayed.Carrier | Statistics.Minutes Delayed.Late Aircraft | Statistics.Minutes Delayed.National Aviation System | Statistics.Minutes Delayed.Security | Statistics.Minutes Delayed.Total | Statistics.Minutes Delayed.Weather | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | ATL | Atlanta, GA: Hartsfield-Jackson Atlanta Intern... | 2003/06 | 6 | June | 2003 | 1009 | 1275 | 3217 | 17 | ... | 5843 | 27 | 23974 | 30060 | 61606 | 68335 | 118831 | 518 | 268764 | 19474 |
1 | BOS | Boston, MA: Logan International | 2003/06 | 6 | June | 2003 | 374 | 495 | 685 | 3 | ... | 1623 | 3 | 7875 | 9639 | 20319 | 28189 | 24400 | 99 | 77167 | 4160 |
2 rows × 24 columns
def delayed(n): print('The Airport code at the top of the list that have the most weather delayed for 2008/05') print(column.sort_values(ascending=False).head(n))
delayed(1)
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-8-0878dcdf71c7> in <module>
----> 1 weatherDelays= ordered.iloc[0]
2 Airport= weatherDelays[aiportName]
3 print(Airport)
NameError: name 'ordered' is not defined