Professional Documents
Culture Documents
In [2]: df = pd.read_csv('flights.csv')
df.head()
Out[2]:
year month day dep_time sched_dep_time dep_delay arr_time sched_arr_time arr_delay
http://localhost:8888/notebooks/DMML/lab4.ipynb# Page 1 of 14
lab4 - Jupyter Notebook 1/24/23, 5:12 PM
In [5]: df.isna().sum()
Out[5]: year 0
month 0
day 0
dep_time 8255
sched_dep_time 0
dep_delay 8255
arr_time 8713
sched_arr_time 0
arr_delay 9430
carrier 0
flight 0
tailnum 2512
origin 0
dest 0
air_time 9430
distance 0
hour 0
minute 0
time_hour 0
dtype: int64
http://localhost:8888/notebooks/DMML/lab4.ipynb# Page 2 of 14
lab4 - Jupyter Notebook 1/24/23, 5:12 PM
Out[7]:
year month day dep_time sched_dep_time dep_delay arr_time sched_arr_time arr_delay carrier
http://localhost:8888/notebooks/DMML/lab4.ipynb# Page 3 of 14
lab4 - Jupyter Notebook 1/24/23, 5:12 PM
Out[8]:
day dep_time sched_dep_time dep_delay arr_time sched_arr_time arr_delay carrier flight tailnum
http://localhost:8888/notebooks/DMML/lab4.ipynb# Page 4 of 14
lab4 - Jupyter Notebook 1/24/23, 5:12 PM
Out[10]:
sched_dep_time dep_delay arr_time sched_arr_time arr_delay carrier flight tailnum origin
http://localhost:8888/notebooks/DMML/lab4.ipynb# Page 5 of 14
lab4 - Jupyter Notebook 1/24/23, 5:12 PM
Out[36]:
year month day dep_time sched_dep_time dep_delay arr_time sched_arr_time arr_del
In [37]: df.tailnum.iloc[0]
Out[37]: 'N383HA'
http://localhost:8888/notebooks/DMML/lab4.ipynb# Page 6 of 14
lab4 - Jupyter Notebook 1/24/23, 5:12 PM
Out[34]:
dep_time sched_dep_time dep_delay arr_time sched_arr_time arr_delay carrier flight tailnum origin
Out[23]: 8713
http://localhost:8888/notebooks/DMML/lab4.ipynb# Page 7 of 14
lab4 - Jupyter Notebook 1/24/23, 5:12 PM
Out[27]: 328063
http://localhost:8888/notebooks/DMML/lab4.ipynb# Page 8 of 14
lab4 - Jupyter Notebook 1/24/23, 5:12 PM
In [41]: df1.groupby('date')['cancelled'].count()
Out[41]: date
2013-01-01 5
2013-01-02 10
2013-01-03 10
2013-01-04 6
2013-01-05 3
..
2013-12-27 2
2013-12-28 1
2013-12-29 19
2013-12-30 14
2013-12-31 16
Name: cancelled, Length: 359, dtype: int64
Out[49]:
date num of flights
0 2013-01-01 5
1 2013-01-02 10
2 2013-01-03 10
3 2013-01-04 6
4 2013-01-05 3
354 2013-12-27 2
355 2013-12-28 1
356 2013-12-29 19
357 2013-12-30 14
358 2013-12-31 16
http://localhost:8888/notebooks/DMML/lab4.ipynb# Page 9 of 14
lab4 - Jupyter Notebook 1/24/23, 5:12 PM
Out[53]:
date avg arr delay
0 2013-01-01 12.651023
1 2013-01-02 12.692888
2 2013-01-03 5.733333
3 2013-01-04 -1.932819
4 2013-01-05 -1.525802
http://localhost:8888/notebooks/DMML/lab4.ipynb# Page 10 of 14
lab4 - Jupyter Notebook 1/24/23, 5:12 PM
Out[54]:
date avg dep delay
0 2013-01-01 11.548926
1 2013-01-02 13.858824
2 2013-01-03 10.987832
3 2013-01-04 8.951595
4 2013-01-05 5.732218
http://localhost:8888/notebooks/DMML/lab4.ipynb# Page 11 of 14
lab4 - Jupyter Notebook 1/24/23, 5:12 PM
Out[57]:
num of flights avg arr delay avg dep delay
date
http://localhost:8888/notebooks/DMML/lab4.ipynb# Page 12 of 14
lab4 - Jupyter Notebook 1/24/23, 5:12 PM
http://localhost:8888/notebooks/DMML/lab4.ipynb# Page 13 of 14
lab4 - Jupyter Notebook 1/24/23, 5:12 PM
iher
In [ ]:
http://localhost:8888/notebooks/DMML/lab4.ipynb# Page 14 of 14