<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 record schedules for 2 weeks, then augment count with weekly flight numbers.
seasonal and seasonal charter will count as once per week for 3 months, so 12/52 per week. TGM separate, since its history is in the past.
Step1:  sch checks out with source
Step2:  mdf checks out with source
<ASSISTANT_TASK:>
Python Code:
for i in locations:
    print i
    if i not in sch:sch[i]={}
    #march 11-24 = 2 weeks
    for d in range (11,25):
        if d not in sch[i]:
            try:
                url=airportialinks[i]
                full=url+'arrivals/201703'+str(d)
                m=requests.get(full).content
                sch[i][full]=pd.read_html(m)[0]
                #print full
            except: pass #print 'no tables',i,d
for i in range(11,25):
    testurl=u'https://www.airportia.com/jordan/queen-alia-international-airport/arrivals/201703'+str(i)
    print 'nr. of flights on March',i,':',len(sch['AMM'][testurl])
testurl=u'https://www.airportia.com/jordan/queen-alia-international-airport/arrivals/20170318'
k=sch['AMM'][testurl]
k[k['From']=='Frankfurt FRA']
Explanation: record schedules for 2 weeks, then augment count with weekly flight numbers.
seasonal and seasonal charter will count as once per week for 3 months, so 12/52 per week. TGM separate, since its history is in the past.
End of explanation
mdf=pd.DataFrame()
for i in sch:
    for d in sch[i]:
        df=sch[i][d].drop(sch[i][d].columns[3:],axis=1).drop(sch[i][d].columns[0],axis=1)
        df['To']=i
        df['Date']=d
        mdf=pd.concat([mdf,df])
mdf['City']=[i[:i.rfind(' ')] for i in mdf['From']]
mdf['Airport']=[i[i.rfind(' ')+1:] for i in mdf['From']]
k=mdf[mdf['Date']==testurl]
k[k['From']=='Frankfurt FRA']
Explanation: sch checks out with source
End of explanation
file("mdf_jo_arrv.json",'w').write(json.dumps(mdf.reset_index().to_json()))
len(mdf)
airlines=set(mdf['Airline'])
cities=set(mdf['City'])
file("cities_jo_arrv.json",'w').write(json.dumps(list(cities)))
file("airlines_jo_arrv.json",'w').write(json.dumps(list(airlines)))
citycoords={}
for i in cities:
    if i not in citycoords:
        if i==u'Birmingham': z='Birmingham, UK'
        elif i==u'Valencia': z='Valencia, Spain'
        elif i==u'Naples': z='Naples, Italy'
        elif i==u'St. Petersburg': z='St. Petersburg, Russia'
        elif i==u'Bristol': z='Bristol, UK'
        elif i==u'Beida': z='Bayda, Libya'
        else: z=i
        citycoords[i]=Geocoder(apik).geocode(z)
        print i
citysave={}
for i in citycoords:
    citysave[i]={"coords":citycoords[i][0].coordinates,
                 "country":citycoords[i][0].country}
file("citysave_jo_arrv.json",'w').write(json.dumps(citysave))
Explanation: mdf checks out with source
End of explanation
<END_TASK>