-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate_eleme_instance.py
31 lines (27 loc) · 1.13 KB
/
generate_eleme_instance.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
import os
import math
import numpy as np
import pandas as pd
order_data_path = '.\eleme_round1_testB\order'
filename = 'order_20200301.txt'
order_data1 = pd.read_csv(os.path.join(order_data_path,filename))
def zoning_from_date(data, lng1, lng2, lat1, lat2):
data = data.drop(columns= ['tracking_id', 'weather_grade', 'create_time', 'confirm_time', 'assigned_time', 'aoi_id'])
zoned_data = data[(lng1 <= data['pick_lng']) &
(lng2 >= data['pick_lng']) &
(lat1 <= data['pick_lat']) &
(lat2 >= data['pick_lat'])].copy(deep = True)
return zoned_data
def sample_from_data(data, case_num, courier_num):
cases = []; iloc1 = 0; iloc2 = 0
for i in range(case_num):
ccount = 1
curname = data.iloc[iloc1]['courier_id']
while ccount <= courier_num: #find the the right indexes to select
iloc2 += 1
if data.iloc[iloc2]['courier_id'] != curname:
curname = data.iloc[iloc2]['courier_id']
ccount += 1
cases.append(data.iloc[iloc1:iloc2].copy(deep = True))
iloc1 = iloc2
return cases