Question
Python Pandas, Series and DataFrame Question (NO Loops, No If Statements, No List Comprehensions) The file flight_delays.csv contains information about flight delays from the month
Python Pandas, Series and DataFrame Question (NO Loops, No If Statements, No List Comprehensions)
The file flight_delays.csv contains information about flight delays from the month of January. Write a function named most_delayed_flights. Modify your most_delayed_flights so that it only takes one parameter (the file name). Now the function should return all regular flights (operated 3x or more per week) that are delayed more often than the overall delay rate for that particular carrier.
Find below the file, flight_delays.csv: Please note this is only a fraction of the file as I couldn't attach the entire file because it's a bit large.
CRS_DEP_TIME | CARRIER | DEP_TIME | DEST | DISTANCE | FL_DATE | FL_NUM | ORIGIN | Weather | DAY_WEEK | DAY_OF_MONTH | TAIL_NUM | Flight Status |
1455 | OH | 1455 | JFK | 184 | 37987 | 5935 | BWI | 0 | 4 | 1 | N940CA | ontime |
1640 | DH | 1640 | JFK | 213 | 37987 | 6155 | DCA | 0 | 4 | 1 | N405FJ | ontime |
1245 | DH | 1245 | LGA | 229 | 37987 | 7208 | IAD | 0 | 4 | 1 | N695BR | ontime |
1715 | DH | 1709 | LGA | 229 | 37987 | 7215 | IAD | 0 | 4 | 1 | N662BR | ontime |
1039 | DH | 1035 | LGA | 229 | 37987 | 7792 | IAD | 0 | 4 | 1 | N698BR | ontime |
840 | DH | 839 | JFK | 228 | 37987 | 7800 | IAD | 0 | 4 | 1 | N687BR | ontime |
1240 | DH | 1243 | JFK | 228 | 37987 | 7806 | IAD | 0 | 4 | 1 | N321UE | ontime |
1645 | DH | 1644 | JFK | 228 | 37987 | 7810 | IAD | 0 | 4 | 1 | N301UE | ontime |
1715 | DH | 1710 | JFK | 228 | 37987 | 7812 | IAD | 0 | 4 | 1 | N328UE | ontime |
2120 | DH | 2129 | JFK | 228 | 37987 | 7814 | IAD | 0 | 4 | 1 | N685BR | ontime |
2120 | DH | 2114 | LGA | 229 | 37987 | 7924 | IAD | 0 | 4 | 1 | N645BR | ontime |
1455 | DL | 1458 | JFK | 213 | 37987 | 746 | DCA | 0 | 4 | 1 | N918DE | ontime |
930 | DL | 932 | LGA | 214 | 37987 | 1746 | DCA | 0 | 4 | 1 | N242DL | ontime |
1230 | DL | 1228 | LGA | 214 | 37987 | 1752 | DCA | 0 | 4 | 1 | N241DL | ontime |
1430 | DL | 1429 | LGA | 214 | 37987 | 1756 | DCA | 0 | 4 | 1 | N242DL | ontime |
1730 | DL | 1728 | LGA | 214 | 37987 | 1762 | DCA | 0 | 4 | 1 | N241DL | ontime |
2030 | DL | 2029 | LGA | 214 | 37987 | 1768 | DCA | 0 | 4 | 1 | N242DL | ontime |
1530 | MQ | 1525 | JFK | 213 | 37987 | 4752 | DCA | 0 | 4 | 1 | N709MQ | ontime |
600 | MQ | 556 | JFK | 213 | 37987 | 4760 | DCA | 0 | 4 | 1 | N717MQ | ontime |
1830 | MQ | 1822 | JFK | 213 | 37987 | 4784 | DCA | 0 | 4 | 1 | N707MQ | ontime |
900 | MQ | 853 | LGA | 214 | 37987 | 4956 | DCA | 0 | 4 | 1 | N737MQ | ontime |
1300 | MQ | 1254 | LGA | 214 | 37987 | 4964 | DCA | 0 | 4 | 1 | N717MQ | ontime |
1400 | MQ | 1356 | LGA | 214 | 37987 | 4966 | DCA | 0 | 4 | 1 | N726MQ | ontime |
1500 | MQ | 1452 | LGA | 214 | 37987 | 4968 | DCA | 0 | 4 | 1 | N724MQ | ontime |
1900 | MQ | 1853 | LGA | 214 | 37987 | 4976 | DCA | 0 | 4 | 1 | N724MQ | ontime |
850 | UA | 841 | LGA | 229 | 37987 | 846 | IAD | 0 | 4 | 1 | N513UA | ontime |
900 | US | 858 | LGA | 214 | 37987 | 2164 | DCA | 0 | 4 | 1 | N709UW | ontime |
1100 | US | 1056 | LGA | 214 | 37987 | 2168 | DCA | 0 | 4 | 1 | N748UW | ontime |
1300 | US | 1253 | LGA | 214 | 37987 | 2172 | DCA | 0 | 4 | 1 | N709UW | ontime |
1500 | US | 1458 | LGA | 214 | 37987 | 2176 | DCA | 0 | 4 | 1 | N748UW | ontime |
1700 | US | 1655 | LGA | 214 | 37987 | 2180 | DCA | 0 | 4 | 1 | N709UW | ontime |
2100 | US | 2055 | LGA | 214 | 37987 | 2188 | DCA | 0 | 4 | 1 | N709UW | ontime |
1455 | RU | 1452 | EWR | 169 | 37987 | 2403 | BWI | 0 | 4 | 1 | N14916 | ontime |
1720 | RU | 1710 | EWR | 169 | 37987 | 2675 | BWI | 0 | 4 | 1 | N16954 | ontime |
1030 | RU | 1030 | EWR | 169 | 37987 | 2303 | BWI | 0 | 4 | 1 | N26549 | ontime |
700 | RU | 656 | EWR | 169 | 37987 | 2703 | BWI | 0 | 4 | 1 | N16954 | ontime |
1300 | CO | 1256 | EWR | 199 | 37987 | 808 | DCA | 0 | 4 | 1 | N18611 | ontime |
1730 | CO | 1726 | EWR | 199 | 37987 | 814 | DCA | 0 | 4 | 1 | N19357 | ontime |
840 | DH | 840 | EWR | 213 | 37987 | 7299 | IAD | 0 | 4 | 1 | N691BR | ontime |
1710 | DH | 1704 | EWR | 213 | 37987 | 7302 | IAD | 0 | 4 | 1 | N691BR | ontime |
1245 | DH | 1245 | EWR | 213 | 37987 | 7303 | IAD | 0 | 4 | 1 | N697BR | ontime |
2120 | DH | 2118 | EWR | 213 | 37987 | 7304 | IAD | 0 | 4 | 1 | N699BR | ontime |
1700 | RU | 1651 | EWR | 213 | 37987 | 2497 | IAD | 0 | 4 | 1 | N12540 | ontime |
1900 | RU | 1850 | EWR | 213 | 37987 | 2385 | IAD | 0 | 4 | 1 | N16149 | ontime |
1525 | RU | 1521 | EWR | 199 | 37987 | 2261 | DCA | 0 | 4 | 1 | N12564 | ontime |
1900 | RU | 1855 | EWR | 199 | 37987 | 2336 | DCA | 0 | 4 | 1 | N21537 | ontime |
1400 | RU | 1357 | EWR | 199 | 37987 | 2216 | DCA | 0 | 4 | 1 | N15983 | ontime |
1515 | RU | 1508 | EWR | 213 | 37987 | 2156 | IAD | 0 | 4 | 1 | N16149 | ontime |
1300 | RU | 1255 | EWR | 213 | 37987 | 2664 | IAD | 0 | 4 | 1 | N12519 | ontime |
1630 | RU | 1625 | EWR | 199 | 37987 | 2181 | DCA | 0 | 4 | 1 | N19966 | ontime |
1455 | OH | 1455 | JFK | 184 | 37988 | 5935 | BWI | 0 | 5 | 2 | N995CA | ontime |
1640 | DH | 1641 | JFK | 213 | 37988 | 6155 | DCA | 0 | 5 | 2 | N415FJ | ontime |
1245 | DH | 1249 | LGA | 229 | 37988 | 7208 | IAD | 0 | 5 | 2 | N688BR | ontime |
1455 | DH | 1531 | LGA | 229 | 37988 | 7211 | IAD | 0 | 5 | 2 | N665BR | delayed |
1715 | DH | 1712 | LGA | 229 | 37988 | 7215 | IAD | 0 | 5 | 2 | N639BR | ontime |
640 | DH | 645 | LGA | 229 | 37988 | 7790 | IAD | 0 | 5 | 2 | N686BR | ontime |
1039 | DH | 1236 | LGA | 229 | 37988 | 7792 | IAD | 0 | 5 | 2 | N665BR | delayed |
840 | DH | 859 | JFK | 228 | 37988 | 7800 | IAD | 0 | 5 | 2 | N645BR | ontime |
1240 | DH | 1232 | JFK | 228 | 37988 | 7806 | IAD | 0 | 5 | 2 | N332UE | ontime |
1455 | DH | 1455 | JFK | 228 | 37988 | 7808 | IAD | 0 | 5 | 2 | N324UE | ontime |
1645 | DH | 1645 | JFK | 228 | 37988 | 7810 | IAD | 0 | 5 | 2 | N305UE | ontime |
1715 | DH | 1716 | JFK | 228 | 37988 | 7812 | IAD | 0 | 5 | 2 | N322UE | ontime |
2120 | DH | 2305 | JFK | 228 | 37988 | 7814 | IAD | 0 | 5 | 2 | N657BR | delayed |
1610 | DH | 1605 | JFK | 228 | 37988 | 7816 | IAD | 0 | 5 | 2 | N315UE | ontime |
2120 | DH | 2118 | LGA | 229 | 37988 | 7924 | IAD | 0 | 5 | 2 | N709BR | ontime |
1455 | DL | 1458 | JFK | 213 | 37988 | 746 | DCA | 0 | 5 | 2 | N964DL | ontime |
930 | DL | 930 | LGA | 214 | 37988 | 1746 | DCA | 0 | 5 | 2 | N241DL | ontime |
1230 | DL | 1230 | LGA | 214 | 37988 | 1752 | DCA | 0 | 5 | 2 | N225DL | ontime |
1430 | DL | 1427 | LGA | 214 | 37988 | 1756 | DCA | 0 | 5 | 2 | N241DL | ontime |
1730 | DL | 1730 | LGA | 214 | 37988 | 1762 | DCA | 0 | 5 | 2 | N225DL | ontime |
2030 | DL | 2028 | LGA | 214 | 37988 | 1768 | DCA | 0 | 5 | 2 | N241DL | ontime |
1530 | MQ | 1522 | JFK | 213 | 37988 | 4752 | DCA | 0 | 5 | 2 | N720MQ | ontime |
600 | MQ | 552 | JFK | 213 | 37988 | 4760 | DCA | 0 | 5 | 2 | N736MQ | ontime |
1830 | MQ | 1847 | JFK | 213 | 37988 | 4784 | DCA | 0 | 5 | 2 | N727MQ | ontime |
900 | MQ | 852 | LGA | 214 | 37988 | 4956 | DCA | 0 | 5 | 2 | N713MQ | ontime |
1100 | MQ | 1053 | LGA | 214 | 37988 | 4960 | DCA | 0 | 5 | 2 | N708MQ | ontime |
1300 | MQ | 1258 | LGA | 214 | 37988 | 4964 | DCA | 0 | 5 | 2 | N713MQ | ontime |
1400 | MQ | 1402 | LGA | 214 | 37988 | 4966 | DCA | 0 | 5 | 2 | N718MQ | ontime |
1500 | MQ | 1456 | LGA | 214 | 37988 | 4968 | DCA | 0 | 5 | 2 | N708MQ | ontime |
850 | UA | 850 | LGA | 229 | 37988 | 846 | IAD | 0 | 5 | 2 | N556UA | ontime |
700 | US | 657 | LGA | 214 | 37988 | 2160 | DCA | 0 | 5 | 2 | N710UW | ontime |
900 | US | 857 | LGA | 214 | 37988 | 2164 | DCA | 0 | 5 | 2 | N736UW | ontime |
1100 | US | 1058 | LGA | 214 | 37988 | 2168 | DCA | 0 | 5 | 2 | N710UW | ontime |
1300 | US | 1258 | LGA | 214 | 37988 | 2172 | DCA | 0 | 5 | 2 | N736UW | ontime |
1500 | US | 1458 | LGA | 214 | 37988 | 2176 | DCA | 0 | 5 | 2 | N710UW | ontime |
1700 | US | 1655 | LGA | 214 | 37988 | 2180 | DCA | 0 | 5 | 2 | N736UW | ontime |
1900 | US | 1855 | LGA | 214 | 37988 | 2184 | DCA | 0 | 5 | 2 | N710UW | ontime |
2100 | US | 2056 | LGA | 214 | 37988 | 2188 | DCA | 0 | 5 | 2 | N736UW | ontime |
1720 | RU | 1715 | EWR | 169 | 37988 | 2675 | BWI | 0 | 5 | 2 | N19966 | ontime |
1030 | RU | 1030 | EWR | 169 | 37988 | 2303 | BWI | 0 | 5 | 2 | N12540 | ontime |
700 | RU | 656 | EWR | 169 | 37988 | 2703 | BWI | 0 | 5 | 2 | N16961 | ontime |
1455 | RU | 1456 | EWR | 169 | 37988 | 2403 | BWI | 0 | 5 | 2 | N12946 | ontime |
1730 | CO | 1727 | EWR | 199 | 37988 | 814 | DCA | 0 | 5 | 2 | N14342 | ontime |
1300 | CO | 1301 | EWR | 199 | 37988 | 808 | DCA | 0 | 5 | 2 | N14664 | ontime |
759 | CO | 754 | EWR | 199 | 37988 | 806 | DCA | 0 | 5 | 2 | N11641 | ontime |
840 | DH | 837 | EWR | 213 | 37988 | 7299 | IAD | 0 | 5 | 2 | N679BR | ontime |
1245 | DH | 1350 | EWR | 213 | 37988 | 7303 | IAD | 0 | 5 | 2 | N686BR | delayed |
1430 | DH | 1512 | EWR | 213 | 37988 | 7307 | IAD | 0 | 5 | 2 | N309UE | delayed |
630 | DH | 629 | EWR | 213 | 37988 | 7371 | IAD | 0 | 5 | 2 | N312UE | ontime |
1630 | RU | 1625 | EWR | 199 | 37988 | 2181 | DCA | 0 | 5 | 2 | N14977 | ontime |
700 | RU | 655 | EWR | 213 | 37988 | 2855 | IAD | 0 | 5 | 2 | N13990 | ontime |
900 | RU | 858 | EWR | 199 | 37988 | 2582 | DCA | 0 | 5 | 2 | N14907 | ontime |
700 | RU | 657 | EWR | 199 | 37988 | 2761 | DCA | 0 | 5 | 2 | N13997 | ontime |
1700 | RU | 1650 | EWR | 213 | 37988 | 2497 | IAD | 0 | 5 | 2 | N12528 | ontime |
1900 | RU | 1856 | EWR | 213 | 37988 | 2385 | IAD | 0 | 5 | 2 | N11107 | ontime |
1300 | RU | 1253 | EWR | 213 | 37988 | 2692 | IAD | 0 | 5 | 2 | N14505 | ontime |
900 | RU | 854 | EWR | 213 | 37988 | 3276 | IAD | 0 | 5 | 2 | N16151 | ontime |
1900 | RU | 1858 | EWR | 199 | 37988 | 2336 | DCA | 0 | 5 | 2 | N15985 | ontime |
2100 | RU | 2050 | EWR | 199 | 37988 | 2879 | DCA | 0 | 5 | 2 | N17108 | ontime |
1400 | RU | 1358 | EWR | 199 | 37988 | 2216 | DCA | 0 | 5 | 2 | N13118 | ontime |
1515 | RU | 1510 | EWR | 213 | 37988 | 2156 | IAD | 0 | 5 | 2 | N11107 | delayed |
1525 | RU | 1519 | EWR | 199 | 37988 | 2261 | DCA | 0 | 5 | 2 | N15574 | ontime |
1245 | DH | 1243 | LGA | 229 | 37989 | 7208 | IAD | 0 | 6 | 3 | N688BR | ontime |
1715 | DH | 1738 | LGA | 229 | 37989 | 7215 | IAD | 0 | 6 | 3 | N639BR | ontime |
640 | DH | 640 | LGA | 229 | 37989 | 7790 | IAD | 0 | 6 | 3 | N696BR | ontime |
1039 | DH | 1030 | LGA | 229 | 37989 | 7792 | IAD | 0 | 6 | 3 | N696BR | ontime |
840 | DH | 855 | JFK | 228 | 37989 | 7800 | IAD | 0 | 6 | 3 | N709BR | ontime |
1240 | DH | 1237 | JFK | 228 | 37989 | 7806 | IAD | 0 | 6 | 3 | N327UE | ontime |
1455 | DH | 1455 | JFK | 228 | 37989 | 7808 | IAD | 0 | 6 | 3 | N309UE | ontime |
1645 | DH | 1654 | JFK | 228 | 37989 | 7810 | IAD | 0 | 6 | 3 | N311UE | ontime |
1715 | DH | 1741 | JFK | 228 | 37989 | 7812 | IAD | 0 | 6 | 3 | N327UE | ontime |
2120 | DH | 2213 | JFK | 228 | 37989 | 7814 | IAD | 0 | 6 | 3 | N655BR | delayed |
1610 | DH | 1604 | JFK | 228 | 37989 | 7816 | IAD | 0 | 6 | 3 | N329UE | ontime |
2120 | DH | 2138 | LGA | 229 | 37989 | 7924 | IAD | 0 | 6 | 3 | N688BR | ontime |
1455 | DL | 1505 | JFK | 213 | 37989 | 746 | DCA | 0 | 6 | 3 | N997DL | delayed |
830 | DL | 828 | LGA | 214 | 37989 | 1744 | DCA | 0 | 6 | 3 | N225DL | ontime |
1030 | DL | 1030 | LGA | 214 | 37989 | 1748 | DCA | 0 | 6 | 3 | N242DL | ontime |
1230 | DL | 1230 | LGA | 214 | 37989 | 1752 | DCA | 0 | 6 | 3 | N225DL | ontime |
1430 | DL | 1428 | LGA | 214 | 37989 | 1756 | DCA | 0 | 6 | 3 | N242DL | ontime |
1630 | DL | 1629 | LGA | 214 | 37989 | 1760 | DCA | 0 | 6 | 3 | N225DL | ontime |
1830 | DL | 1829 | LGA | 214 | 37989 | 1764 | DCA | 0 | 6 | 3 | N242DL | ontime |
2030 | DL | 2024 | LGA | 214 | 37989 | 1768 | DCA | 0 | 6 | 3 | N225DL | ontime |
1530 | MQ | 1600 | JFK | 213 | 37989 | 4752 | DCA | 0 | 6 | 3 | N734MQ | delayed |
600 | MQ | 555 | JFK | 213 | 37989 | 4760 | DCA | 0 | 6 | 3 | N712MQ | ontime |
1830 | MQ | 1829 | JFK | 213 | 37989 | 4784 | DCA | 0 | 6 | 3 | N709MQ | ontime |
900 | MQ | 855 | LGA | 214 | 37989 | 4956 | DCA | 0 | 6 | 3 | N739MQ | ontime |
1300 | MQ | 1254 | LGA | 214 | 37989 | 4964 | DCA | 0 | 6 | 3 | N739MQ | ontime |
850 | UA | 849 | LGA | 229 | 37989 | 846 | IAD | 0 | 6 | 3 | N567UA | ontime |
700 | US | 655 | LGA | 214 | 37989 | 2160 | DCA | 0 | 6 | 3 | N760UW | ontime |
900 | US | 858 | LGA | 214 | 37989 | 2164 | DCA | 0 | 6 | 3 | N710UW | ontime |
1100 | US | 1059 | LGA | 214 | 37989 | 2168 | DCA | 0 | 6 | 3 | N760UW | ontime |
1300 | US | 1256 | LGA | 214 | 37989 | 2172 | DCA | 0 | 6 | 3 | N710UW | ontime |
1500 | US | 1500 | LGA | 214 | 37989 | 2176 | DCA | 0 | 6 | 3 | N760UW | ontime |
1700 | US | 1658 | LGA | 214 | 37989 | 2180 | DCA | 0 | 6 | 3 | N710UW | ontime |
1900 | US | 1857 | LGA | 214 | 37989 | 2184 | DCA | 0 | 6 | 3 | N760UW | ontime |
1720 | RU | 1714 | EWR | 169 | 37989 | 2675 | BWI | 0 | 6 | 3 | N15574 | ontime |
700 | RU | 655 | EWR | 169 | 37989 | 2703 | BWI | 0 | 6 | 3 | N11536 | ontime |
1030 | RU | 1026 | EWR | 169 | 37989 | 2303 | BWI | 0 | 6 | 3 | N14907 | ontime |
1455 | RU | 1448 | EWR | 169 | 37989 | 2267 | BWI | 0 | 6 | 3 | N14974 | ontime |
1300 | CO | 1255 | EWR | 199 | 37989 | 808 | DCA | 0 | 6 | 3 | N11612 | ontime |
840 | DH | 857 | EWR | 213 | 37989 | 7299 | IAD | 0 | 6 | 3 | N693BR | delayed |
1710 | DH | 1705 | EWR | 213 | 37989 | 7302 | IAD | 0 | 6 | 3 | N693BR | ontime |
1245 | DH | 1329 | EWR | 213 | 37989 | 7303 | IAD | 0 | 6 | 3 | N672BR | delayed |
2120 | DH | 2126 | EWR | 213 | 37989 | 7304 | IAD | 0 | 6 | 3 | N643BR | ontime |
630 | DH | 625 | EWR | 213 | 37989 | 7371 | IAD | 0 | 6 | 3 | N333UE | ontime |
1725 | RU | 1722 | EWR | 213 | 37989 | 2497 | IAD | 0 | 6 | 3 | N17146 | ontime |
1400 | RU | 1356 | EWR | 199 | 37989 | 2216 | DCA | 0 | 6 | 3 | N17513 | ontime |
700 | RU | 658 | EWR | 213 | 37989 | 2855 | IAD | 0 | 6 | 3 | N14925 | ontime |
930 | RU | 941 | EWR | 199 | 37989 | 2582 | DCA | 0 | 6 | 3 | N14977 | ontime |
1730 | RU | 1738 | EWR | 199 | 37989 | 2097 | DCA | 0 | 6 | 3 | N14998 | ontime |
1600 | RU | 1556 | EWR | 199 | 37989 | 2181 | DCA | 0 | 6 | 3 | N13955 | ontime |
1515 | RU | 1511 | EWR | 213 | 37989 | 2156 | IAD | 0 | 6 | 3 | N12136 | ontime |
700 | RU | 703 | EWR | 199 | 37989 | 2761 | DCA | 0 | 6 | 3 | N14907 | ontime |
1455 | OH | 1605 | JFK | 184 | 37990 | 5935 | BWI | 0 | 7 | 4 | N973CA | delayed |
1640 | DH | 1644 | JFK | 213 | 37990 | 6155 | DCA | 0 | 7 | 4 | N424FJ | ontime |
1245 | DH | 1249 | LGA | 229 | 37990 | 7208 | IAD | 0 | 7 | 4 | N632BR | ontime |
1455 | DH | 1535 | LGA | 229 | 37990 | 7211 | IAD | 0 | 7 | 4 | N654BR | delayed |
1715 | DH | 1837 | LGA | 229 | 37990 | 7215 | IAD | 0 | 7 | 4 | N634BR | delayed |
640 | DH | 640 | LGA | 229 | 37990 | 7790 | IAD | 0 | 7 | 4 | N654BR | ontime |
1039 | DH | 1032 | LGA | 229 | 37990 | 7792 | IAD | 0 | 7 | 4 | N654BR | ontime |
840 | DH | 900 | JFK | 228 | 37990 | 7800 | IAD | 0 | 7 | 4 | N673BR | ontime |
1240 | DH | 1243 | JFK | 228 | 37990 | 7806 | IAD | 0 | 7 | 4 | N330UE | ontime |
1455 | DH | 1504 | JFK | 228 | 37990 | 7808 | IAD | 0 | 7 | 4 | N314UE | ontime |
1645 | DH | 1642 | JFK | 228 | 37990 | 7810 | IAD | 0 | 7 | 4 | N313UE | ontime |
1715 | DH | 1709 | JFK | 228 | 37990 | 7812 | IAD | 0 | 7 | 4 | N312UE | ontime |
2120 | DH | 2120 | JFK | 228 | 37990 | 7814 | IAD | 0 | 7 | 4 | N626BR | ontime |
1610 | DH | 1607 | JFK | 228 | 37990 | 7816 | IAD | 0 | 7 | 4 | N327UE | ontime |
2120 | DH | 2116 | LGA | 229 | 37990 | 7924 | IAD | 0 | 7 | 4 | N674BR | ontime |
1455 | DL | 1500 | JFK | 213 | 37990 | 746 | DCA | 0 | 7 | 4 | N912DL | ontime |
830 | DL | 828 | LGA | 214 | 37990 | 1744 | DCA | 0 | 7 | 4 | N242DL | ontime |
1030 | DL | 1028 | LGA | 214 | 37990 | 1748 | DCA | 0 | 7 | 4 | N221DL | ontime |
1230 | DL | 1230 | LGA | 214 | 37990 | 1752 | DCA | 0 | 7 | 4 | N242DL | ontime |
1430 | DL | 1432 | LGA | 214 | 37990 | 1756 | DCA | 0 | 7 | 4 | N221DL | ontime |
1630 | DL | 1629 | LGA | 214 | 37990 | 1760 | DCA | 0 | 7 | 4 | N242DL | ontime |
1830 | DL | 1832 | LGA | 214 | 37990 | 1764 | DCA | 0 | 7 | 4 | N221DL | ontime |
2030 | DL | 2030 | LGA | 214 | 37990 | 1768 | DCA | 0 | 7 | 4 | N242DL | ontime |
1530 | MQ | 1534 | JFK | 213 | 37990 | 4752 | DCA | 0 | 7 | 4 | N712MQ | delayed |
600 | MQ | 554 | JFK | 213 | 37990 | 4760 | DCA | 0 | 7 | 4 | N737MQ | ontime |
730 | MQ | 745 | JFK | 213 | 37990 | 4771 | DCA | 0 | 7 | 4 | N719MQ | ontime |
1830 | MQ | 1858 | JFK | 213 | 37990 | 4784 | DCA | 0 | 7 | 4 | N727MQ | delayed |
1300 | MQ | 1257 | LGA | 214 | 37990 | 4964 | DCA | 0 | 7 | 4 | N737MQ | ontime |
1500 | MQ | 1458 | LGA | 214 | 37990 | 4968 | DCA | 0 | 7 | 4 | N727MQ | delayed |
1700 | MQ | 1659 | LGA | 214 | 37990 | 4972 | DCA | 0 | 7 | 4 | N708MQ | ontime |
1900 | MQ | 1936 | LGA | 214 | 37990 | 4976 | DCA | 0 | 7 | 4 | N719MQ | delayed |
850 | UA | 849 | LGA | 229 | 37990 | 846 | IAD | 0 | 7 | 4 | N559UA | ontime |
900 | US | 858 | LGA | 214 | 37990 | 2164 | DCA | 0 | 7 | 4 | N730UW | ontime |
1000 | US | 954 | LGA | 214 | 37990 | 2166 | DCA | 0 | 7 | 4 | N765UW | ontime |
1100 | US | 1055 | LGA | 214 | 37990 | 2168 | DCA | 0 | 7 | 4 | N746UW | ontime |
1200 | US | 1158 | LGA | 214 | 37990 | 2170 | DCA | 0 | 7 | 4 | N711UW | ontime |
1300 | US | 1257 | LGA | 214 | 37990 | 2172 | DCA | 0 | 7 | 4 | N730UW | ontime |
Here is an example call and results:
In [1]: most_delayed_flights('flight_delays.csv') Out[1]: CARRIER FL_NUM CO 814 0.600000 DH 7211 0.600000 7215 0.428571 7302 0.333333 7303 0.714286 7304 0.333333 7307 0.600000 7812 0.285714 7814 0.571429 DL 746 0.142857 1766 0.333333 MQ 4752 0.285714 4784 0.333333
4968 0.600000 4970 0.666667 4976 0.600000 RU 2156 0.571429 2261 0.400000 2303 0.428571 2336 0.500000 2385 0.600000 2403 0.333333 US 1479 0.333333 2176 0.142857 2178 0.250000 2186 0.250000 dtype: float64
For example, Continental Airlines (CO) has an overall delay rate of almost 37%, so all CO flights delayed more often than this rate appear in the list. Discovery Airways (DH) has an overall delay rate of 25.6%, so all DH ights delayed more often than this rate appear in the list, and so on. Your manager feels that these results will be more indicative of problem flights!
Point of Stress: This is strictly a Pandas, Series and DataFrame question (Pls no loops, no lf statements, no list comprehension). Please attach a print screen in addition to the code as evidence the scripts ran properly and as intended. Thanks.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started