-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquery.py
More file actions
72 lines (52 loc) · 2.07 KB
/
Copy pathquery.py
File metadata and controls
72 lines (52 loc) · 2.07 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import pandas as pd
import numpy as np
school_center = pd.read_table('dataset/school-center.tsv')
school_center_distance = pd.read_table('dataset/school-center-distance.tsv')
school_lat_long = pd.read_table('dataset/schools_lat_long_2081.tsv')
def extract_lat_lon(scode):
"""
Takes school code(scode) and returns latitude and longitude values for the school
"""
filt_ = school_lat_long[school_lat_long['scode'] == scode]
lat, lon = filt_[['lat', 'long']].to_numpy()[0]
return lat, lon
def extract_school_details(scode, school_type="school"):
"""
Takes school code (scode) and returns school name
"""
if school_type == 'center':
filter_ = school_center[school_center['cscode'] == scode]['center'].reset_index(drop=True)[0]
return filter_
filter_ = school_center[school_center['scode'] == scode]['school'].reset_index(drop=True)[0]
return filter_
def get_centers_by_location(center_address):
"""
:param center_address: address of center
:return: list of schools by address
"""
centers_detail = school_center[school_center['center_address'] == center_address]['center']
return list(centers_detail.unique())
def list_of_centers():
"""
:return: list of all centers
"""
a = list(school_center['center'].unique())
return a
def list_of_schools():
"""
:return: list of all the schools
"""
a = list(school_center['school'].unique())
return a
def center_colleges(center_name):
data = school_center[school_center['center'] == center_name]
return data
def schools_assigned_to_center(center_name):
filt = school_center[['center', 'scode', 'school', 'center_address', 'allocation', 'distance_km']]
return filt[filt['center'] == center_name]
def centers_assigned_to_school(school_name):
school = school_center[school_center['school'] == school_name]
return school[['school', 'center', 'cscode', 'allocation', 'distance_km']]
def get_schoolcode_by_name(school_name):
school = school_center[school_center['school'] == school_name]
return school['scode'].iloc[0]