{ "cells": [ { "cell_type": "code", "execution_count": 34, "metadata": { "collapsed": true }, "outputs": [], "source": [ "import pandas as pd, json, numpy as np\n", "import matplotlib.pyplot as plt\n", "%matplotlib inline" ] }, { "cell_type": "code", "execution_count": 35, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from pygeocoder import Geocoder\n", "apik='AIzaSyDybC2OroTE_XDJTuxjKruxFpby5VDhEGk'" ] }, { "cell_type": "code", "execution_count": 73, "metadata": { "collapsed": true }, "outputs": [], "source": [ "locations=json.loads(file('locations_hu.json','r').read())" ] }, { "cell_type": "code", "execution_count": 74, "metadata": { "collapsed": false }, "outputs": [], "source": [ "mdf_dest=pd.read_json(json.loads(file('mdf_hu_dest.json','r').read()))\n", "mdf_arrv=pd.read_json(json.loads(file('mdf_hu_arrv.json','r').read()))" ] }, { "cell_type": "code", "execution_count": 75, "metadata": { "collapsed": true }, "outputs": [], "source": [ "citysave_dest=json.loads(file('citysave_hu_dest.json','r').read())\n", "citysave_arrv=json.loads(file('citysave_hu_arrv.json','r').read())" ] }, { "cell_type": "code", "execution_count": 76, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
AirlineAirportCityDateFromToindexID
0Wizz AirLTNLondonhttps://www.airportia.com/hungary/debrecen-int...DEBLondon LTN0DEB
1Wizz AirEINEindhovenhttps://www.airportia.com/hungary/debrecen-int...DEBEindhoven EIN1DEB
10LufthansaMUCMunichhttps://www.airportia.com/hungary/debrecen-int...DEBMunich MUC1DEB
100LufthansaMUCMunichhttps://www.airportia.com/hungary/budapest-lis...BUDMunich MUC68BUD
1000Brussels AirlinesBRUBrusselshttps://www.airportia.com/hungary/budapest-lis...BUDBrussels BRU92BUD
\n", "
" ], "text/plain": [ " Airline Airport City \\\n", "0 Wizz Air LTN London \n", "1 Wizz Air EIN Eindhoven \n", "10 Lufthansa MUC Munich \n", "100 Lufthansa MUC Munich \n", "1000 Brussels Airlines BRU Brussels \n", "\n", " Date From To \\\n", "0 https://www.airportia.com/hungary/debrecen-int... DEB London LTN \n", "1 https://www.airportia.com/hungary/debrecen-int... DEB Eindhoven EIN \n", "10 https://www.airportia.com/hungary/debrecen-int... DEB Munich MUC \n", "100 https://www.airportia.com/hungary/budapest-lis... BUD Munich MUC \n", "1000 https://www.airportia.com/hungary/budapest-lis... BUD Brussels BRU \n", "\n", " index ID \n", "0 0 DEB \n", "1 1 DEB \n", "10 1 DEB \n", "100 68 BUD \n", "1000 92 BUD " ] }, "execution_count": 76, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mdf_dest['ID']=mdf_dest['From']\n", "mdf_dest.head()" ] }, { "cell_type": "code", "execution_count": 77, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
AirlineAirportCityDateFromToindexID
0LufthansaMUCMunichhttps://www.airportia.com/hungary/debrecen-int...Munich MUCDEB0DEB
1Wizz AirBGYMilanhttps://www.airportia.com/hungary/debrecen-int...Milan BGYDEB1DEB
10Wizz AirEINEindhovenhttps://www.airportia.com/hungary/debrecen-int...Eindhoven EINDEB1DEB
100EasyJetGVAGenevahttps://www.airportia.com/hungary/budapest-lis...Geneva GVABUD68BUD
1000GermanwingsDUSDusseldorfhttps://www.airportia.com/hungary/budapest-lis...Dusseldorf DUSBUD79BUD
\n", "
" ], "text/plain": [ " Airline Airport City \\\n", "0 Lufthansa MUC Munich \n", "1 Wizz Air BGY Milan \n", "10 Wizz Air EIN Eindhoven \n", "100 EasyJet GVA Geneva \n", "1000 Germanwings DUS Dusseldorf \n", "\n", " Date From To \\\n", "0 https://www.airportia.com/hungary/debrecen-int... Munich MUC DEB \n", "1 https://www.airportia.com/hungary/debrecen-int... Milan BGY DEB \n", "10 https://www.airportia.com/hungary/debrecen-int... Eindhoven EIN DEB \n", "100 https://www.airportia.com/hungary/budapest-lis... Geneva GVA BUD \n", "1000 https://www.airportia.com/hungary/budapest-lis... Dusseldorf DUS BUD \n", "\n", " index ID \n", "0 0 DEB \n", "1 1 DEB \n", "10 1 DEB \n", "100 68 BUD \n", "1000 79 BUD " ] }, "execution_count": 77, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mdf_arrv['ID']=mdf_arrv['To']\n", "mdf_arrv.head()" ] }, { "cell_type": "code", "execution_count": 78, "metadata": { "collapsed": true }, "outputs": [], "source": [ "mdf=pd.concat([mdf_dest,mdf_arrv])" ] }, { "cell_type": "code", "execution_count": 79, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "1572" ] }, "execution_count": 79, "metadata": {}, "output_type": "execute_result" } ], "source": [ "len(mdf_dest)" ] }, { "cell_type": "code", "execution_count": 80, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "1584" ] }, "execution_count": 80, "metadata": {}, "output_type": "execute_result" } ], "source": [ "len(mdf_arrv)" ] }, { "cell_type": "code", "execution_count": 81, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
AirlineAirportCityDateFromToindexID
0Wizz AirLTNLondonhttps://www.airportia.com/hungary/debrecen-int...DEBLondon LTN0DEB
1Wizz AirEINEindhovenhttps://www.airportia.com/hungary/debrecen-int...DEBEindhoven EIN1DEB
10LufthansaMUCMunichhttps://www.airportia.com/hungary/debrecen-int...DEBMunich MUC1DEB
100LufthansaMUCMunichhttps://www.airportia.com/hungary/budapest-lis...BUDMunich MUC68BUD
1000Brussels AirlinesBRUBrusselshttps://www.airportia.com/hungary/budapest-lis...BUDBrussels BRU92BUD
1001British AirwaysLHRLondonhttps://www.airportia.com/hungary/budapest-lis...BUDLondon LHR93BUD
1002Qatar AirwaysDOHDohahttps://www.airportia.com/hungary/budapest-lis...BUDDoha DOH94BUD
1003RyanairCIARomehttps://www.airportia.com/hungary/budapest-lis...BUDRome CIA95BUD
1004Wizz AirCRLBrusselshttps://www.airportia.com/hungary/budapest-lis...BUDBrussels CRL96BUD
1005Jet2EMAEast Midlandshttps://www.airportia.com/hungary/budapest-lis...BUDEast Midlands EMA97BUD
1006Austrian AirlinesVIEViennahttps://www.airportia.com/hungary/budapest-lis...BUDVienna VIE98BUD
1007Wizz AirLTNLondonhttps://www.airportia.com/hungary/budapest-lis...BUDLondon LTN99BUD
1008LufthansaFRAFrankfurthttps://www.airportia.com/hungary/budapest-lis...BUDFrankfurt FRA100BUD
1009Air BerlinTXLBerlinhttps://www.airportia.com/hungary/budapest-lis...BUDBerlin TXL101BUD
101BH AirCDGParishttps://www.airportia.com/hungary/budapest-lis...BUDParis CDG69BUD
1010Jet2LBALeedshttps://www.airportia.com/hungary/budapest-lis...BUDLeeds LBA102BUD
1011Wizz AirNCENicehttps://www.airportia.com/hungary/budapest-lis...BUDNice NCE103BUD
1012Czech AirlinesPRGPraguehttps://www.airportia.com/hungary/budapest-lis...BUDPrague PRG104BUD
1013Wizz AirMXPMilanhttps://www.airportia.com/hungary/budapest-lis...BUDMilan MXP105BUD
1014RyanairATHAthenshttps://www.airportia.com/hungary/budapest-lis...BUDAthens ATH106BUD
1015GermanwingsSTRStuttgarthttps://www.airportia.com/hungary/budapest-lis...BUDStuttgart STR107BUD
1016RyanairBCNBarcelonahttps://www.airportia.com/hungary/budapest-lis...BUDBarcelona BCN108BUD
1017SwissZRHZurichhttps://www.airportia.com/hungary/budapest-lis...BUDZurich ZRH109BUD
1018Air ChinaPEKBeijinghttps://www.airportia.com/hungary/budapest-lis...BUDBeijing PEK110BUD
1019TransaviaORYParishttps://www.airportia.com/hungary/budapest-lis...BUDParis ORY111BUD
102Wizz AirAGPMalagahttps://www.airportia.com/hungary/budapest-lis...BUDMalaga AGP70BUD
1020RyanairCRLBrusselshttps://www.airportia.com/hungary/budapest-lis...BUDBrussels CRL112BUD
1021EurowingsDUSDusseldorfhttps://www.airportia.com/hungary/budapest-lis...BUDDusseldorf DUS113BUD
1022Turkish AirlinesISTIstanbulhttps://www.airportia.com/hungary/budapest-lis...BUDIstanbul IST114BUD
1023LufthansaMUCMunichhttps://www.airportia.com/hungary/budapest-lis...BUDMunich MUC115BUD
...........................
972EasyJetSXFBerlinhttps://www.airportia.com/hungary/budapest-lis...Berlin SXFBUD51BUD
973EasyJetGVAGenevahttps://www.airportia.com/hungary/budapest-lis...Geneva GVABUD52BUD
974LufthansaMUCMunichhttps://www.airportia.com/hungary/budapest-lis...Munich MUCBUD53BUD
975Air FranceCDGParishttps://www.airportia.com/hungary/budapest-lis...Paris CDGBUD54BUD
976EasyJetLGWLondonhttps://www.airportia.com/hungary/budapest-lis...London LGWBUD55BUD
977Wizz AirFCORomehttps://www.airportia.com/hungary/budapest-lis...Rome FCOBUD56BUD
978KLMAMSAmsterdamhttps://www.airportia.com/hungary/budapest-lis...Amsterdam AMSBUD57BUD
979Wizz AirCLJCluj-Napocahttps://www.airportia.com/hungary/budapest-lis...Cluj-Napoca CLJBUD58BUD
98EasyJetCDGParishttps://www.airportia.com/hungary/budapest-lis...Paris CDGBUD66BUD
980RyanairBRSBristolhttps://www.airportia.com/hungary/budapest-lis...Bristol BRSBUD59BUD
981LOTWAWWarsawhttps://www.airportia.com/hungary/budapest-lis...Warsaw WAWBUD60BUD
982RyanairBLLBillundhttps://www.airportia.com/hungary/budapest-lis...Billund BLLBUD61BUD
983AlitaliaFCORomehttps://www.airportia.com/hungary/budapest-lis...Rome FCOBUD62BUD
984CargoluxHKGHong Konghttps://www.airportia.com/hungary/budapest-lis...Hong Kong HKGBUD63BUD
985British AirwaysLHRLondonhttps://www.airportia.com/hungary/budapest-lis...London LHRBUD64BUD
986Brussels AirlinesBRUBrusselshttps://www.airportia.com/hungary/budapest-lis...Brussels BRUBUD65BUD
987Wizz AirMLALuqahttps://www.airportia.com/hungary/budapest-lis...Luqa MLABUD66BUD
988LufthansaFRAFrankfurthttps://www.airportia.com/hungary/budapest-lis...Frankfurt FRABUD67BUD
989Wizz AirLTNLondonhttps://www.airportia.com/hungary/budapest-lis...London LTNBUD68BUD
99RyanairBVAParishttps://www.airportia.com/hungary/budapest-lis...Paris BVABUD67BUD
990Austrian AirlinesVIEViennahttps://www.airportia.com/hungary/budapest-lis...Vienna VIEBUD69BUD
991FinnairHELHelsinkihttps://www.airportia.com/hungary/budapest-lis...Helsinki HELBUD70BUD
992Air BerlinTXLBerlinhttps://www.airportia.com/hungary/budapest-lis...Berlin TXLBUD71BUD
993Wizz AirHHNFrankfurthttps://www.airportia.com/hungary/budapest-lis...Frankfurt HHNBUD72BUD
994Wizz AirSOFSofiahttps://www.airportia.com/hungary/budapest-lis...Sofia SOFBUD73BUD
995SwissZRHZurichhttps://www.airportia.com/hungary/budapest-lis...Zurich ZRHBUD74BUD
996TaromOTPBucharesthttps://www.airportia.com/hungary/budapest-lis...Bucharest OTPBUD75BUD
997EurowingsSTRStuttgarthttps://www.airportia.com/hungary/budapest-lis...Stuttgart STRBUD76BUD
998Czech AirlinesPRGPraguehttps://www.airportia.com/hungary/budapest-lis...Prague PRGBUD77BUD
999Turkish AirlinesISTIstanbulhttps://www.airportia.com/hungary/budapest-lis...Istanbul ISTBUD78BUD
\n", "

3156 rows × 8 columns

\n", "
" ], "text/plain": [ " Airline Airport City \\\n", "0 Wizz Air LTN London \n", "1 Wizz Air EIN Eindhoven \n", "10 Lufthansa MUC Munich \n", "100 Lufthansa MUC Munich \n", "1000 Brussels Airlines BRU Brussels \n", "1001 British Airways LHR London \n", "1002 Qatar Airways DOH Doha \n", "1003 Ryanair CIA Rome \n", "1004 Wizz Air CRL Brussels \n", "1005 Jet2 EMA East Midlands \n", "1006 Austrian Airlines VIE Vienna \n", "1007 Wizz Air LTN London \n", "1008 Lufthansa FRA Frankfurt \n", "1009 Air Berlin TXL Berlin \n", "101 BH Air CDG Paris \n", "1010 Jet2 LBA Leeds \n", "1011 Wizz Air NCE Nice \n", "1012 Czech Airlines PRG Prague \n", "1013 Wizz Air MXP Milan \n", "1014 Ryanair ATH Athens \n", "1015 Germanwings STR Stuttgart \n", "1016 Ryanair BCN Barcelona \n", "1017 Swiss ZRH Zurich \n", "1018 Air China PEK Beijing \n", "1019 Transavia ORY Paris \n", "102 Wizz Air AGP Malaga \n", "1020 Ryanair CRL Brussels \n", "1021 Eurowings DUS Dusseldorf \n", "1022 Turkish Airlines IST Istanbul \n", "1023 Lufthansa MUC Munich \n", "... ... ... ... \n", "972 EasyJet SXF Berlin \n", "973 EasyJet GVA Geneva \n", "974 Lufthansa MUC Munich \n", "975 Air France CDG Paris \n", "976 EasyJet LGW London \n", "977 Wizz Air FCO Rome \n", "978 KLM AMS Amsterdam \n", "979 Wizz Air CLJ Cluj-Napoca \n", "98 EasyJet CDG Paris \n", "980 Ryanair BRS Bristol \n", "981 LOT WAW Warsaw \n", "982 Ryanair BLL Billund \n", "983 Alitalia FCO Rome \n", "984 Cargolux HKG Hong Kong \n", "985 British Airways LHR London \n", "986 Brussels Airlines BRU Brussels \n", "987 Wizz Air MLA Luqa \n", "988 Lufthansa FRA Frankfurt \n", "989 Wizz Air LTN London \n", "99 Ryanair BVA Paris \n", "990 Austrian Airlines VIE Vienna \n", "991 Finnair HEL Helsinki \n", "992 Air Berlin TXL Berlin \n", "993 Wizz Air HHN Frankfurt \n", "994 Wizz Air SOF Sofia \n", "995 Swiss ZRH Zurich \n", "996 Tarom OTP Bucharest \n", "997 Eurowings STR Stuttgart \n", "998 Czech Airlines PRG Prague \n", "999 Turkish Airlines IST Istanbul \n", "\n", " Date From \\\n", "0 https://www.airportia.com/hungary/debrecen-int... DEB \n", "1 https://www.airportia.com/hungary/debrecen-int... DEB \n", "10 https://www.airportia.com/hungary/debrecen-int... DEB \n", "100 https://www.airportia.com/hungary/budapest-lis... BUD \n", "1000 https://www.airportia.com/hungary/budapest-lis... BUD \n", "1001 https://www.airportia.com/hungary/budapest-lis... BUD \n", "1002 https://www.airportia.com/hungary/budapest-lis... BUD \n", "1003 https://www.airportia.com/hungary/budapest-lis... BUD \n", "1004 https://www.airportia.com/hungary/budapest-lis... BUD \n", "1005 https://www.airportia.com/hungary/budapest-lis... BUD \n", "1006 https://www.airportia.com/hungary/budapest-lis... BUD \n", "1007 https://www.airportia.com/hungary/budapest-lis... BUD \n", "1008 https://www.airportia.com/hungary/budapest-lis... BUD \n", "1009 https://www.airportia.com/hungary/budapest-lis... BUD \n", "101 https://www.airportia.com/hungary/budapest-lis... BUD \n", "1010 https://www.airportia.com/hungary/budapest-lis... BUD \n", "1011 https://www.airportia.com/hungary/budapest-lis... BUD \n", "1012 https://www.airportia.com/hungary/budapest-lis... BUD \n", "1013 https://www.airportia.com/hungary/budapest-lis... BUD \n", "1014 https://www.airportia.com/hungary/budapest-lis... BUD \n", "1015 https://www.airportia.com/hungary/budapest-lis... BUD \n", "1016 https://www.airportia.com/hungary/budapest-lis... BUD \n", "1017 https://www.airportia.com/hungary/budapest-lis... BUD \n", "1018 https://www.airportia.com/hungary/budapest-lis... BUD \n", "1019 https://www.airportia.com/hungary/budapest-lis... BUD \n", "102 https://www.airportia.com/hungary/budapest-lis... BUD \n", "1020 https://www.airportia.com/hungary/budapest-lis... BUD \n", "1021 https://www.airportia.com/hungary/budapest-lis... BUD \n", "1022 https://www.airportia.com/hungary/budapest-lis... BUD \n", "1023 https://www.airportia.com/hungary/budapest-lis... BUD \n", "... ... ... \n", "972 https://www.airportia.com/hungary/budapest-lis... Berlin SXF \n", "973 https://www.airportia.com/hungary/budapest-lis... Geneva GVA \n", "974 https://www.airportia.com/hungary/budapest-lis... Munich MUC \n", "975 https://www.airportia.com/hungary/budapest-lis... Paris CDG \n", "976 https://www.airportia.com/hungary/budapest-lis... London LGW \n", "977 https://www.airportia.com/hungary/budapest-lis... Rome FCO \n", "978 https://www.airportia.com/hungary/budapest-lis... Amsterdam AMS \n", "979 https://www.airportia.com/hungary/budapest-lis... Cluj-Napoca CLJ \n", "98 https://www.airportia.com/hungary/budapest-lis... Paris CDG \n", "980 https://www.airportia.com/hungary/budapest-lis... Bristol BRS \n", "981 https://www.airportia.com/hungary/budapest-lis... Warsaw WAW \n", "982 https://www.airportia.com/hungary/budapest-lis... Billund BLL \n", "983 https://www.airportia.com/hungary/budapest-lis... Rome FCO \n", "984 https://www.airportia.com/hungary/budapest-lis... Hong Kong HKG \n", "985 https://www.airportia.com/hungary/budapest-lis... London LHR \n", "986 https://www.airportia.com/hungary/budapest-lis... Brussels BRU \n", "987 https://www.airportia.com/hungary/budapest-lis... Luqa MLA \n", "988 https://www.airportia.com/hungary/budapest-lis... Frankfurt FRA \n", "989 https://www.airportia.com/hungary/budapest-lis... London LTN \n", "99 https://www.airportia.com/hungary/budapest-lis... Paris BVA \n", "990 https://www.airportia.com/hungary/budapest-lis... Vienna VIE \n", "991 https://www.airportia.com/hungary/budapest-lis... Helsinki HEL \n", "992 https://www.airportia.com/hungary/budapest-lis... Berlin TXL \n", "993 https://www.airportia.com/hungary/budapest-lis... Frankfurt HHN \n", "994 https://www.airportia.com/hungary/budapest-lis... Sofia SOF \n", "995 https://www.airportia.com/hungary/budapest-lis... Zurich ZRH \n", "996 https://www.airportia.com/hungary/budapest-lis... Bucharest OTP \n", "997 https://www.airportia.com/hungary/budapest-lis... Stuttgart STR \n", "998 https://www.airportia.com/hungary/budapest-lis... Prague PRG \n", "999 https://www.airportia.com/hungary/budapest-lis... Istanbul IST \n", "\n", " To index ID \n", "0 London LTN 0 DEB \n", "1 Eindhoven EIN 1 DEB \n", "10 Munich MUC 1 DEB \n", "100 Munich MUC 68 BUD \n", "1000 Brussels BRU 92 BUD \n", "1001 London LHR 93 BUD \n", "1002 Doha DOH 94 BUD \n", "1003 Rome CIA 95 BUD \n", "1004 Brussels CRL 96 BUD \n", "1005 East Midlands EMA 97 BUD \n", "1006 Vienna VIE 98 BUD \n", "1007 London LTN 99 BUD \n", "1008 Frankfurt FRA 100 BUD \n", "1009 Berlin TXL 101 BUD \n", "101 Paris CDG 69 BUD \n", "1010 Leeds LBA 102 BUD \n", "1011 Nice NCE 103 BUD \n", "1012 Prague PRG 104 BUD \n", "1013 Milan MXP 105 BUD \n", "1014 Athens ATH 106 BUD \n", "1015 Stuttgart STR 107 BUD \n", "1016 Barcelona BCN 108 BUD \n", "1017 Zurich ZRH 109 BUD \n", "1018 Beijing PEK 110 BUD \n", "1019 Paris ORY 111 BUD \n", "102 Malaga AGP 70 BUD \n", "1020 Brussels CRL 112 BUD \n", "1021 Dusseldorf DUS 113 BUD \n", "1022 Istanbul IST 114 BUD \n", "1023 Munich MUC 115 BUD \n", "... ... ... ... \n", "972 BUD 51 BUD \n", "973 BUD 52 BUD \n", "974 BUD 53 BUD \n", "975 BUD 54 BUD \n", "976 BUD 55 BUD \n", "977 BUD 56 BUD \n", "978 BUD 57 BUD \n", "979 BUD 58 BUD \n", "98 BUD 66 BUD \n", "980 BUD 59 BUD \n", "981 BUD 60 BUD \n", "982 BUD 61 BUD \n", "983 BUD 62 BUD \n", "984 BUD 63 BUD \n", "985 BUD 64 BUD \n", "986 BUD 65 BUD \n", "987 BUD 66 BUD \n", "988 BUD 67 BUD \n", "989 BUD 68 BUD \n", "99 BUD 67 BUD \n", "990 BUD 69 BUD \n", "991 BUD 70 BUD \n", "992 BUD 71 BUD \n", "993 BUD 72 BUD \n", "994 BUD 73 BUD \n", "995 BUD 74 BUD \n", "996 BUD 75 BUD \n", "997 BUD 76 BUD \n", "998 BUD 77 BUD \n", "999 BUD 78 BUD \n", "\n", "[3156 rows x 8 columns]" ] }, "execution_count": 81, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mdf" ] }, { "cell_type": "code", "execution_count": 82, "metadata": { "collapsed": false }, "outputs": [], "source": [ "mdg=mdf.set_index(['ID','City','Airport','Airline'])" ] }, { "cell_type": "code", "execution_count": 83, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
DateFromToindex
Airline
Lufthansahttps://www.airportia.com/hungary/budapest-lis...BUDFrankfurt FRA79
Lufthansahttps://www.airportia.com/hungary/budapest-lis...BUDFrankfurt FRA12
Lufthansahttps://www.airportia.com/hungary/budapest-lis...BUDFrankfurt FRA30
Lufthansahttps://www.airportia.com/hungary/budapest-lis...BUDFrankfurt FRA57
\n", "
" ], "text/plain": [ " Date From \\\n", "Airline \n", "Lufthansa https://www.airportia.com/hungary/budapest-lis... BUD \n", "Lufthansa https://www.airportia.com/hungary/budapest-lis... BUD \n", "Lufthansa https://www.airportia.com/hungary/budapest-lis... BUD \n", "Lufthansa https://www.airportia.com/hungary/budapest-lis... BUD \n", "\n", " To index \n", "Airline \n", "Lufthansa Frankfurt FRA 79 \n", "Lufthansa Frankfurt FRA 12 \n", "Lufthansa Frankfurt FRA 30 \n", "Lufthansa Frankfurt FRA 57 " ] }, "execution_count": 83, "metadata": {}, "output_type": "execute_result" } ], "source": [ "k=mdg.loc['BUD'].loc['Frankfurt'].loc['FRA']\n", "testurl=u'https://www.airportia.com/hungary/budapest-liszt-ferenc-international-airport/departures/20170318'\n", "k[k['Date']==testurl]" ] }, { "cell_type": "code", "execution_count": 84, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
DateFromToindex
Airline
Lufthansahttps://www.airportia.com/hungary/budapest-lis...Frankfurt FRABUD14
Lufthansahttps://www.airportia.com/hungary/budapest-lis...Frankfurt FRABUD41
Lufthansahttps://www.airportia.com/hungary/budapest-lis...Frankfurt FRABUD61
Lufthansahttps://www.airportia.com/hungary/budapest-lis...Frankfurt FRABUD79
\n", "
" ], "text/plain": [ " Date From \\\n", "Airline \n", "Lufthansa https://www.airportia.com/hungary/budapest-lis... Frankfurt FRA \n", "Lufthansa https://www.airportia.com/hungary/budapest-lis... Frankfurt FRA \n", "Lufthansa https://www.airportia.com/hungary/budapest-lis... Frankfurt FRA \n", "Lufthansa https://www.airportia.com/hungary/budapest-lis... Frankfurt FRA \n", "\n", " To index \n", "Airline \n", "Lufthansa BUD 14 \n", "Lufthansa BUD 41 \n", "Lufthansa BUD 61 \n", "Lufthansa BUD 79 " ] }, "execution_count": 84, "metadata": {}, "output_type": "execute_result" } ], "source": [ "k=mdg.loc['BUD'].loc['Frankfurt'].loc['FRA']\n", "testurl=u'https://www.airportia.com/hungary/budapest-liszt-ferenc-international-airport/arrivals/20170318'\n", "k[k['Date']==testurl]" ] }, { "cell_type": "code", "execution_count": 85, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "BUD-FRA March 11 departures 4 arrivals 4\n", "BUD-FRA March 12 departures 4 arrivals 4\n", "BUD-FRA March 13 departures 4 arrivals 4\n", "BUD-FRA March 14 departures 4 arrivals 4\n", "BUD-FRA March 15 departures 4 arrivals 4\n", "BUD-FRA March 16 departures 4 arrivals 4\n", "BUD-FRA March 17 departures 4 arrivals 4\n", "BUD-FRA March 18 departures 4 arrivals 4\n", "BUD-FRA March 19 departures 4 arrivals 4\n", "BUD-FRA March 20 departures 4 arrivals 4\n", "BUD-FRA March 21 departures 4 arrivals 4\n", "BUD-FRA March 22 departures 4 arrivals 4\n", "BUD-FRA March 23 departures 4 arrivals 4\n", "BUD-FRA March 24 departures 4 arrivals 4\n" ] } ], "source": [ "k=mdg.loc['BUD'].loc['Frankfurt'].loc['FRA']\n", "for i in range(11,25):\n", " testurl=u'https://www.airportia.com/hungary/budapest-liszt-ferenc-international-airport/departures/201703'+str(i)\n", " print 'BUD-FRA March',i, 'departures',len(k[k['Date']==testurl]),\n", " testurl=u'https://www.airportia.com/hungary/budapest-liszt-ferenc-international-airport/arrivals/201703'+str(i)\n", " print 'arrivals', len(k[k['Date']==testurl])" ] }, { "cell_type": "code", "execution_count": 88, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "8" ] }, "execution_count": 88, "metadata": {}, "output_type": "execute_result" } ], "source": [ "len(k)/14" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "`mdg` checks out with source" ] }, { "cell_type": "code", "execution_count": 89, "metadata": { "collapsed": false }, "outputs": [], "source": [ "flights={}\n", "minn=1.0 #want to see minimum 1 flight in the past 2 weeks\n", "for i in mdg.index.get_level_values(0).unique():\n", " #2 weeks downloaded. want to get weekly freq. but multi by 2 dept+arrv\n", " d=4.0\n", " if i not in flights:flights[i]={}\n", " for j in mdg.loc[i].index.get_level_values(0).unique():\n", " if len(mdg.loc[i].loc[j])>minn: #minimum 1 flights required in this period at least once every 2 weeks\n", " if j not in flights[i]:flights[i][j]={'airports':{},'7freq':0}\n", " flights[i][j]['7freq']=len(mdg.loc[i].loc[j])/d \n", " for k in mdg.loc[i].loc[j].index.get_level_values(0).unique():\n", " if len(mdg.loc[i].loc[j].loc[k])>minn:\n", " if k not in flights[i][j]['airports']:flights[i][j]['airports'][k]={'airlines':{},'7freq':0}\n", " flights[i][j]['airports'][k]['7freq']=len(mdg.loc[i].loc[j].loc[k])/d\n", " for l in mdg.loc[i].loc[j].loc[k].index.get_level_values(0).unique():\n", " try:\n", " if len(mdg.loc[i].loc[j].loc[k].loc[l])>minn: \n", " if l not in flights[i][j]['airports'][k]['airlines']:flights[i][j]['airports'][k]['airlines'][l]={'7freq':0}\n", " flights[i][j]['airports'][k]['airlines'][l]['7freq']=len(mdg.loc[i].loc[j].loc[k].loc[l])/d\n", " except:pass" ] }, { "cell_type": "code", "execution_count": 90, "metadata": { "collapsed": true }, "outputs": [], "source": [ "file(\"flights_hu.json\",'w').write(json.dumps(flights))" ] } ], "metadata": { "anaconda-cloud": {}, "kernelspec": { "display_name": "Python [conda root]", "language": "python", "name": "conda-root-py" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.12" } }, "nbformat": 4, "nbformat_minor": 1 }