-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelpers.py
36 lines (28 loc) · 1003 Bytes
/
helpers.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import csv
# Returns dictionary of Manhattan stations:
# station_id: {station_name, capacity, lng, lat}
def get_manhattan_stations():
"""Return the list of Manhattan stations from the manhattan_stations.csv file."""
stations_dict = {}
with open("datasets/station_with_demand.csv", "r") as f:
csv_data = csv.reader(f)
next(csv_data) # Skips the header row
for row in csv_data:
stations_dict[row[0]] = {
'station_name': row[1],
'capacity': int(row[2]),
'lng': float(row[3]),
'lat': float(row[4]),
'demand_level': row[8]
}
return stations_dict
def add_benefit_score(stations_dict):
benefit_values = {
'Lowest': 9.82,
'Low': 9.86,
'Medium': 9.88,
'Highest': 9.88
}
for k in stations_dict:
stations_dict[k]['benefit_value'] = benefit_values[stations_dict[k]['demand_level']]
return stations_dict