In [1]:
import functions
import json
In [5]:
stations = functions.get_stations()
trips = functions.most_common_trips(5, 2016)
res = []
for k,v in trips.iteritems():
s1 = stations[stations.id == int(k.split('-')[0])]
s2 = stations[stations.id == int(k.split('-')[1])]
# No se tienen datos de las estaciones 1001 y 1002
try:
f = {'weight': int(v/300) + 1, 'point1': s1.location.iloc[0].split(','), 'point2': s2.location.iloc[0].split(','), 'total': str(v)}
res.append(f)
except:
pass
with open('data/common_trips_saturday.json', 'w') as file:
json.dump(res, file)
In [ ]: