-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata_processing.py
More file actions
28 lines (24 loc) · 810 Bytes
/
data_processing.py
File metadata and controls
28 lines (24 loc) · 810 Bytes
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
import pandas as pd
import haversine as hs
df = pd.read_csv('data/r1_timings_parameters_public.csv')
loc_df = pd.read_csv('countries.csv')
loc_dict = {}
for i, item in loc_df.iterrows():
print
loc_dict[item['ISO']] = (item['latitude'],item['longitude'] )
#locs = df['receiver_cc']
distances = []
s_countries= {}
r_countries= {}
for i, item in df.iterrows():
sender_loc = loc_dict[item['sender_cc'].upper()]
receiver_loc = loc_dict[item['receiver_cc'].upper()]
dist = hs.haversine(sender_loc, receiver_loc)
distances.append(int(dist))
r_countries[item['receiver_cc']] = 0
s_countries[item['sender_cc']] = 0
print(r_countries)
print(s_countries)
df['SR_Distance'] = distances
df = df.rename(columns={"Unnamed: 0": 'id'})
#df.to_csv('data/r1_timings_distance.csv', index=False)