{ "cells": [ { "cell_type": "code", "execution_count": 35, "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": 36, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from pygeocoder import Geocoder\n", "apik='AIzaSyDybC2OroTE_XDJTuxjKruxFpby5VDhEGk'" ] }, { "cell_type": "code", "execution_count": 37, "metadata": { "collapsed": true }, "outputs": [], "source": [ "locations=json.loads(file('locations_ro.json','r').read())" ] }, { "cell_type": "code", "execution_count": 38, "metadata": { "collapsed": false }, "outputs": [], "source": [ "mdf_dest=pd.read_json(json.loads(file('mdf_ro_dest.json','r').read()))\n", "mdf_arrv=pd.read_json(json.loads(file('mdf_ro_arrv.json','r').read()))" ] }, { "cell_type": "code", "execution_count": 39, "metadata": { "collapsed": true }, "outputs": [], "source": [ "citysave_dest=json.loads(file('citysave_ro_dest.json','r').read())\n", "citysave_arrv=json.loads(file('citysave_ro_arrv.json','r').read())" ] }, { "cell_type": "code", "execution_count": 40, "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
0Blue AirBGYMilanhttps://www.airportia.com/romania/bacău-airpor...BCMMilan BGY0BCM
1Blue AirDUBDublinhttps://www.airportia.com/romania/bacău-airpor...BCMDublin DUB1BCM
10Blue AirTRNTurinhttps://www.airportia.com/romania/bacău-airpor...BCMTurin TRN1BCM
100Wizz AirOTPBucharesthttps://www.airportia.com/romania/cluj_napoca-...CLJBucharest OTP25CLJ
1000TaromCLJCluj-Napocahttps://www.airportia.com/romania/henri-coandă...OTPCluj-Napoca CLJ110OTP
\n", "
" ], "text/plain": [ " Airline Airport City \\\n", "0 Blue Air BGY Milan \n", "1 Blue Air DUB Dublin \n", "10 Blue Air TRN Turin \n", "100 Wizz Air OTP Bucharest \n", "1000 Tarom CLJ Cluj-Napoca \n", "\n", " Date From To \\\n", "0 https://www.airportia.com/romania/bacău-airpor... BCM Milan BGY \n", "1 https://www.airportia.com/romania/bacău-airpor... BCM Dublin DUB \n", "10 https://www.airportia.com/romania/bacău-airpor... BCM Turin TRN \n", "100 https://www.airportia.com/romania/cluj_napoca-... CLJ Bucharest OTP \n", "1000 https://www.airportia.com/romania/henri-coandă... OTP Cluj-Napoca CLJ \n", "\n", " index ID \n", "0 0 BCM \n", "1 1 BCM \n", "10 1 BCM \n", "100 25 CLJ \n", "1000 110 OTP " ] }, "execution_count": 40, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mdf_dest['ID']=mdf_dest['From']\n", "mdf_dest.head()" ] }, { "cell_type": "code", "execution_count": 41, "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
0Blue AirBGYMilanhttps://www.airportia.com/romania/bacău-airpor...Milan BGYBCM0BCM
1Blue AirDUBDublinhttps://www.airportia.com/romania/bacău-airpor...Dublin DUBBCM1BCM
10Blue AirLTNLondonhttps://www.airportia.com/romania/bacău-airpor...London LTNBCM1BCM
100Wizz AirBCNBarcelonahttps://www.airportia.com/romania/cluj_napoca-...Barcelona BCNCLJ28CLJ
1000TaromCLJCluj-Napocahttps://www.airportia.com/romania/henri-coandă...Cluj-Napoca CLJOTP108OTP
\n", "
" ], "text/plain": [ " Airline Airport City \\\n", "0 Blue Air BGY Milan \n", "1 Blue Air DUB Dublin \n", "10 Blue Air LTN London \n", "100 Wizz Air BCN Barcelona \n", "1000 Tarom CLJ Cluj-Napoca \n", "\n", " Date From To \\\n", "0 https://www.airportia.com/romania/bacău-airpor... Milan BGY BCM \n", "1 https://www.airportia.com/romania/bacău-airpor... Dublin DUB BCM \n", "10 https://www.airportia.com/romania/bacău-airpor... London LTN BCM \n", "100 https://www.airportia.com/romania/cluj_napoca-... Barcelona BCN CLJ \n", "1000 https://www.airportia.com/romania/henri-coandă... Cluj-Napoca CLJ OTP \n", "\n", " index ID \n", "0 0 BCM \n", "1 1 BCM \n", "10 1 BCM \n", "100 28 CLJ \n", "1000 108 OTP " ] }, "execution_count": 41, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mdf_arrv['ID']=mdf_arrv['To']\n", "mdf_arrv.head()" ] }, { "cell_type": "code", "execution_count": 42, "metadata": { "collapsed": true }, "outputs": [], "source": [ "mdf=pd.concat([mdf_dest,mdf_arrv])" ] }, { "cell_type": "code", "execution_count": 43, "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
0Blue AirBGYMilanhttps://www.airportia.com/romania/bacău-airpor...BCMMilan BGY0BCM
1Blue AirDUBDublinhttps://www.airportia.com/romania/bacău-airpor...BCMDublin DUB1BCM
10Blue AirTRNTurinhttps://www.airportia.com/romania/bacău-airpor...BCMTurin TRN1BCM
100Wizz AirOTPBucharesthttps://www.airportia.com/romania/cluj_napoca-...CLJBucharest OTP25CLJ
1000TaromCLJCluj-Napocahttps://www.airportia.com/romania/henri-coandă...OTPCluj-Napoca CLJ110OTP
1001Turkish AirlinesISTIstanbulhttps://www.airportia.com/romania/henri-coandă...OTPIstanbul IST111OTP
1002TaromKIVChisinauhttps://www.airportia.com/romania/henri-coandă...OTPChisinau KIV112OTP
1003Qatar AirwaysDOHDohahttps://www.airportia.com/romania/henri-coandă...OTPDoha DOH113OTP
1004El AlTLVTel Avivhttps://www.airportia.com/romania/henri-coandă...OTPTel Aviv TLV114OTP
1005TaromBEYBeiruthttps://www.airportia.com/romania/henri-coandă...OTPBeirut BEY115OTP
1006AirSERBIABEGBelgradehttps://www.airportia.com/romania/henri-coandă...OTPBelgrade BEG0OTP
1007KLMAMSAmsterdamhttps://www.airportia.com/romania/henri-coandă...OTPAmsterdam AMS1OTP
1008LOTWAWWarsawhttps://www.airportia.com/romania/henri-coandă...OTPWarsaw WAW2OTP
1009Wizz AirCIARomehttps://www.airportia.com/romania/henri-coandă...OTPRome CIA3OTP
101Air DolomitiMUCMunichhttps://www.airportia.com/romania/cluj_napoca-...CLJMunich MUC0CLJ
1010Wizz AirCRLBrusselshttps://www.airportia.com/romania/henri-coandă...OTPBrussels CRL4OTP
1011LufthansaMUCMunichhttps://www.airportia.com/romania/henri-coandă...OTPMunich MUC5OTP
1012Turkish AirlinesISTIstanbulhttps://www.airportia.com/romania/henri-coandă...OTPIstanbul IST6OTP
1013Wizz AirTLVTel Avivhttps://www.airportia.com/romania/henri-coandă...OTPTel Aviv TLV7OTP
1014Air BerlinTXLBerlinhttps://www.airportia.com/romania/henri-coandă...OTPBerlin TXL8OTP
1015Wizz AirLTNLondonhttps://www.airportia.com/romania/henri-coandă...OTPLondon LTN9OTP
1016Wizz AirDTMDortmundhttps://www.airportia.com/romania/henri-coandă...OTPDortmund DTM10OTP
1017Blue AirFCORomehttps://www.airportia.com/romania/henri-coandă...OTPRome FCO11OTP
1018RyanairCRLBrusselshttps://www.airportia.com/romania/henri-coandă...OTPBrussels CRL12OTP
1019RyanairSTNLondonhttps://www.airportia.com/romania/henri-coandă...OTPLondon STN13OTP
102Wizz AirLTNLondonhttps://www.airportia.com/romania/cluj_napoca-...CLJLondon LTN1CLJ
1020Air FranceCDGParishttps://www.airportia.com/romania/henri-coandă...OTPParis CDG14OTP
1021Blue AirVLCValenciahttps://www.airportia.com/romania/henri-coandă...OTPValencia VLC15OTP
1022TaromTSRTimisoarahttps://www.airportia.com/romania/henri-coandă...OTPTimisoara TSR16OTP
1023Blue AirGLAGlasgowhttps://www.airportia.com/romania/henri-coandă...OTPGlasgow GLA17OTP
...........................
972Blue AirLCALarnacahttps://www.airportia.com/romania/henri-coandă...Larnaca LCAOTP80OTP
973RyanairMXPMilanhttps://www.airportia.com/romania/henri-coandă...Milan MXPOTP81OTP
974Blue AirBVAParishttps://www.airportia.com/romania/henri-coandă...Paris BVAOTP82OTP
975TaromCDGParishttps://www.airportia.com/romania/henri-coandă...Paris CDGOTP83OTP
976DniproaviaKBPKievhttps://www.airportia.com/romania/henri-coandă...Kiev KBPOTP84OTP
977Blue AirLTNLondonhttps://www.airportia.com/romania/henri-coandă...London LTNOTP85OTP
978Blue AirOMROradeahttps://www.airportia.com/romania/henri-coandă...Oradea OMROTP86OTP
979TaromMADMadridhttps://www.airportia.com/romania/henri-coandă...Madrid MADOTP87OTP
98TaromOTPBucharesthttps://www.airportia.com/romania/cluj_napoca-...Bucharest OTPCLJ26CLJ
980LOTWAWWarsawhttps://www.airportia.com/romania/henri-coandă...Warsaw WAWOTP88OTP
981RyanairATHAthenshttps://www.airportia.com/romania/henri-coandă...Athens ATHOTP89OTP
982TaromCLJCluj-Napocahttps://www.airportia.com/romania/henri-coandă...Cluj-Napoca CLJOTP90OTP
983Austrian AirlinesVIEViennahttps://www.airportia.com/romania/henri-coandă...Vienna VIEOTP91OTP
984Wizz AirBUDBudapesthttps://www.airportia.com/romania/henri-coandă...Budapest BUDOTP92OTP
985LufthansaMUCMunichhttps://www.airportia.com/romania/henri-coandă...Munich MUCOTP93OTP
986Qatar AirwaysDOHDohahttps://www.airportia.com/romania/henri-coandă...Doha DOHOTP94OTP
987Wizz AirBGYMilanhttps://www.airportia.com/romania/henri-coandă...Milan BGYOTP95OTP
988Blue AirLINMilanhttps://www.airportia.com/romania/henri-coandă...Milan LINOTP96OTP
989MeridianaLINMilanhttps://www.airportia.com/romania/henri-coandă...Milan LINOTP97OTP
99Wizz AirBGYMilanhttps://www.airportia.com/romania/cluj_napoca-...Milan BGYCLJ27CLJ
990Wizz AirCTACataniahttps://www.airportia.com/romania/henri-coandă...Catania CTAOTP98OTP
991Wizz AirVRNVeronahttps://www.airportia.com/romania/henri-coandă...Verona VRNOTP99OTP
992Blue AirSTRStuttgarthttps://www.airportia.com/romania/henri-coandă...Stuttgart STROTP100OTP
993Blue AirCLJCluj-Napocahttps://www.airportia.com/romania/henri-coandă...Cluj-Napoca CLJOTP101OTP
994RyanairSXFBerlinhttps://www.airportia.com/romania/henri-coandă...Berlin SXFOTP102OTP
995TaromSUJSatu Marehttps://www.airportia.com/romania/henri-coandă...Satu Mare SUJOTP103OTP
996TaromIASIasihttps://www.airportia.com/romania/henri-coandă...Iasi IASOTP104OTP
997TaromKIVChisinauhttps://www.airportia.com/romania/henri-coandă...Chisinau KIVOTP105OTP
998TaromLHRLondonhttps://www.airportia.com/romania/henri-coandă...London LHROTP106OTP
999TaromOMROradeahttps://www.airportia.com/romania/henri-coandă...Oradea OMROTP107OTP
\n", "

6075 rows × 8 columns

\n", "
" ], "text/plain": [ " Airline Airport City \\\n", "0 Blue Air BGY Milan \n", "1 Blue Air DUB Dublin \n", "10 Blue Air TRN Turin \n", "100 Wizz Air OTP Bucharest \n", "1000 Tarom CLJ Cluj-Napoca \n", "1001 Turkish Airlines IST Istanbul \n", "1002 Tarom KIV Chisinau \n", "1003 Qatar Airways DOH Doha \n", "1004 El Al TLV Tel Aviv \n", "1005 Tarom BEY Beirut \n", "1006 AirSERBIA BEG Belgrade \n", "1007 KLM AMS Amsterdam \n", "1008 LOT WAW Warsaw \n", "1009 Wizz Air CIA Rome \n", "101 Air Dolomiti MUC Munich \n", "1010 Wizz Air CRL Brussels \n", "1011 Lufthansa MUC Munich \n", "1012 Turkish Airlines IST Istanbul \n", "1013 Wizz Air TLV Tel Aviv \n", "1014 Air Berlin TXL Berlin \n", "1015 Wizz Air LTN London \n", "1016 Wizz Air DTM Dortmund \n", "1017 Blue Air FCO Rome \n", "1018 Ryanair CRL Brussels \n", "1019 Ryanair STN London \n", "102 Wizz Air LTN London \n", "1020 Air France CDG Paris \n", "1021 Blue Air VLC Valencia \n", "1022 Tarom TSR Timisoara \n", "1023 Blue Air GLA Glasgow \n", "... ... ... ... \n", "972 Blue Air LCA Larnaca \n", "973 Ryanair MXP Milan \n", "974 Blue Air BVA Paris \n", "975 Tarom CDG Paris \n", "976 Dniproavia KBP Kiev \n", "977 Blue Air LTN London \n", "978 Blue Air OMR Oradea \n", "979 Tarom MAD Madrid \n", "98 Tarom OTP Bucharest \n", "980 LOT WAW Warsaw \n", "981 Ryanair ATH Athens \n", "982 Tarom CLJ Cluj-Napoca \n", "983 Austrian Airlines VIE Vienna \n", "984 Wizz Air BUD Budapest \n", "985 Lufthansa MUC Munich \n", "986 Qatar Airways DOH Doha \n", "987 Wizz Air BGY Milan \n", "988 Blue Air LIN Milan \n", "989 Meridiana LIN Milan \n", "99 Wizz Air BGY Milan \n", "990 Wizz Air CTA Catania \n", "991 Wizz Air VRN Verona \n", "992 Blue Air STR Stuttgart \n", "993 Blue Air CLJ Cluj-Napoca \n", "994 Ryanair SXF Berlin \n", "995 Tarom SUJ Satu Mare \n", "996 Tarom IAS Iasi \n", "997 Tarom KIV Chisinau \n", "998 Tarom LHR London \n", "999 Tarom OMR Oradea \n", "\n", " Date From \\\n", "0 https://www.airportia.com/romania/bacău-airpor... BCM \n", "1 https://www.airportia.com/romania/bacău-airpor... BCM \n", "10 https://www.airportia.com/romania/bacău-airpor... BCM \n", "100 https://www.airportia.com/romania/cluj_napoca-... CLJ \n", "1000 https://www.airportia.com/romania/henri-coandă... OTP \n", "1001 https://www.airportia.com/romania/henri-coandă... OTP \n", "1002 https://www.airportia.com/romania/henri-coandă... OTP \n", "1003 https://www.airportia.com/romania/henri-coandă... OTP \n", "1004 https://www.airportia.com/romania/henri-coandă... OTP \n", "1005 https://www.airportia.com/romania/henri-coandă... OTP \n", "1006 https://www.airportia.com/romania/henri-coandă... OTP \n", "1007 https://www.airportia.com/romania/henri-coandă... OTP \n", "1008 https://www.airportia.com/romania/henri-coandă... OTP \n", "1009 https://www.airportia.com/romania/henri-coandă... OTP \n", "101 https://www.airportia.com/romania/cluj_napoca-... CLJ \n", "1010 https://www.airportia.com/romania/henri-coandă... OTP \n", "1011 https://www.airportia.com/romania/henri-coandă... OTP \n", "1012 https://www.airportia.com/romania/henri-coandă... OTP \n", "1013 https://www.airportia.com/romania/henri-coandă... OTP \n", "1014 https://www.airportia.com/romania/henri-coandă... OTP \n", "1015 https://www.airportia.com/romania/henri-coandă... OTP \n", "1016 https://www.airportia.com/romania/henri-coandă... OTP \n", "1017 https://www.airportia.com/romania/henri-coandă... OTP \n", "1018 https://www.airportia.com/romania/henri-coandă... OTP \n", "1019 https://www.airportia.com/romania/henri-coandă... OTP \n", "102 https://www.airportia.com/romania/cluj_napoca-... CLJ \n", "1020 https://www.airportia.com/romania/henri-coandă... OTP \n", "1021 https://www.airportia.com/romania/henri-coandă... OTP \n", "1022 https://www.airportia.com/romania/henri-coandă... OTP \n", "1023 https://www.airportia.com/romania/henri-coandă... OTP \n", "... ... ... \n", "972 https://www.airportia.com/romania/henri-coandă... Larnaca LCA \n", "973 https://www.airportia.com/romania/henri-coandă... Milan MXP \n", "974 https://www.airportia.com/romania/henri-coandă... Paris BVA \n", "975 https://www.airportia.com/romania/henri-coandă... Paris CDG \n", "976 https://www.airportia.com/romania/henri-coandă... Kiev KBP \n", "977 https://www.airportia.com/romania/henri-coandă... London LTN \n", "978 https://www.airportia.com/romania/henri-coandă... Oradea OMR \n", "979 https://www.airportia.com/romania/henri-coandă... Madrid MAD \n", "98 https://www.airportia.com/romania/cluj_napoca-... Bucharest OTP \n", "980 https://www.airportia.com/romania/henri-coandă... Warsaw WAW \n", "981 https://www.airportia.com/romania/henri-coandă... Athens ATH \n", "982 https://www.airportia.com/romania/henri-coandă... Cluj-Napoca CLJ \n", "983 https://www.airportia.com/romania/henri-coandă... Vienna VIE \n", "984 https://www.airportia.com/romania/henri-coandă... Budapest BUD \n", "985 https://www.airportia.com/romania/henri-coandă... Munich MUC \n", "986 https://www.airportia.com/romania/henri-coandă... Doha DOH \n", "987 https://www.airportia.com/romania/henri-coandă... Milan BGY \n", "988 https://www.airportia.com/romania/henri-coandă... Milan LIN \n", "989 https://www.airportia.com/romania/henri-coandă... Milan LIN \n", "99 https://www.airportia.com/romania/cluj_napoca-... Milan BGY \n", "990 https://www.airportia.com/romania/henri-coandă... Catania CTA \n", "991 https://www.airportia.com/romania/henri-coandă... Verona VRN \n", "992 https://www.airportia.com/romania/henri-coandă... Stuttgart STR \n", "993 https://www.airportia.com/romania/henri-coandă... Cluj-Napoca CLJ \n", "994 https://www.airportia.com/romania/henri-coandă... Berlin SXF \n", "995 https://www.airportia.com/romania/henri-coandă... Satu Mare SUJ \n", "996 https://www.airportia.com/romania/henri-coandă... Iasi IAS \n", "997 https://www.airportia.com/romania/henri-coandă... Chisinau KIV \n", "998 https://www.airportia.com/romania/henri-coandă... London LHR \n", "999 https://www.airportia.com/romania/henri-coandă... Oradea OMR \n", "\n", " To index ID \n", "0 Milan BGY 0 BCM \n", "1 Dublin DUB 1 BCM \n", "10 Turin TRN 1 BCM \n", "100 Bucharest OTP 25 CLJ \n", "1000 Cluj-Napoca CLJ 110 OTP \n", "1001 Istanbul IST 111 OTP \n", "1002 Chisinau KIV 112 OTP \n", "1003 Doha DOH 113 OTP \n", "1004 Tel Aviv TLV 114 OTP \n", "1005 Beirut BEY 115 OTP \n", "1006 Belgrade BEG 0 OTP \n", "1007 Amsterdam AMS 1 OTP \n", "1008 Warsaw WAW 2 OTP \n", "1009 Rome CIA 3 OTP \n", "101 Munich MUC 0 CLJ \n", "1010 Brussels CRL 4 OTP \n", "1011 Munich MUC 5 OTP \n", "1012 Istanbul IST 6 OTP \n", "1013 Tel Aviv TLV 7 OTP \n", "1014 Berlin TXL 8 OTP \n", "1015 London LTN 9 OTP \n", "1016 Dortmund DTM 10 OTP \n", "1017 Rome FCO 11 OTP \n", "1018 Brussels CRL 12 OTP \n", "1019 London STN 13 OTP \n", "102 London LTN 1 CLJ \n", "1020 Paris CDG 14 OTP \n", "1021 Valencia VLC 15 OTP \n", "1022 Timisoara TSR 16 OTP \n", "1023 Glasgow GLA 17 OTP \n", "... ... ... ... \n", "972 OTP 80 OTP \n", "973 OTP 81 OTP \n", "974 OTP 82 OTP \n", "975 OTP 83 OTP \n", "976 OTP 84 OTP \n", "977 OTP 85 OTP \n", "978 OTP 86 OTP \n", "979 OTP 87 OTP \n", "98 CLJ 26 CLJ \n", "980 OTP 88 OTP \n", "981 OTP 89 OTP \n", "982 OTP 90 OTP \n", "983 OTP 91 OTP \n", "984 OTP 92 OTP \n", "985 OTP 93 OTP \n", "986 OTP 94 OTP \n", "987 OTP 95 OTP \n", "988 OTP 96 OTP \n", "989 OTP 97 OTP \n", "99 CLJ 27 CLJ \n", "990 OTP 98 OTP \n", "991 OTP 99 OTP \n", "992 OTP 100 OTP \n", "993 OTP 101 OTP \n", "994 OTP 102 OTP \n", "995 OTP 103 OTP \n", "996 OTP 104 OTP \n", "997 OTP 105 OTP \n", "998 OTP 106 OTP \n", "999 OTP 107 OTP \n", "\n", "[6075 rows x 8 columns]" ] }, "execution_count": 43, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mdf" ] }, { "cell_type": "code", "execution_count": 44, "metadata": { "collapsed": false }, "outputs": [], "source": [ "mdg=mdf.set_index(['ID','City','Airport','Airline'])" ] }, { "cell_type": "code", "execution_count": 45, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "6075" ] }, "execution_count": 45, "metadata": {}, "output_type": "execute_result" } ], "source": [ "len(mdg)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "`mdg` check out with source" ] }, { "cell_type": "code", "execution_count": 46, "metadata": { "collapsed": false }, "outputs": [], "source": [ "flights={}\n", "minn=1.0\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 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", " 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" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "manual fix TGM - all flights are departing from CLJ, therefore doublecounting + BUD not represented" ] }, { "cell_type": "code", "execution_count": 47, "metadata": { "collapsed": false }, "outputs": [], "source": [ "flights['TGM']['Budapest']=flights['CLJ']['Budapest']" ] }, { "cell_type": "code", "execution_count": 48, "metadata": { "collapsed": true }, "outputs": [], "source": [ "for j in flights['TGM']:\n", " if flights['CLJ'][j]['7freq']-flights['TGM'][j]['7freq']>0:\n", " flights['CLJ'][j]['7freq']-=flights['TGM'][j]['7freq']\n", " ap=list(flights['TGM'][j]['airports'].keys())[0]\n", " flights['CLJ'][j]['airports'][ap]['7freq']-=flights['TGM'][j]['7freq']\n", " flights['CLJ'][j]['airports'][ap]['airlines'][u'Wizz Air']['7freq']-=flights['TGM'][j]['7freq']\n", " else: flights['CLJ'].pop(j)" ] }, { "cell_type": "code", "execution_count": 49, "metadata": { "collapsed": true }, "outputs": [], "source": [ "file(\"flights_ro.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 }