def find_prev_weather_mode(self, time_slotid, weather_dict=None,): try: prev_slot = singletonTimeslot.getPrevSlots(time_slotid, 1)[0] res = weather_dict[prev_slot] except: current_date = singletonTimeslot.getDate(time_slotid) res = weather_dict[current_date] return pd.Series([res[1]], index = ['preweather'])
def find_prev_weather_mode(self, time_slotid, weather_dict=None,): try: prev_slot = singletonTimeslot.getPrevSlots(time_slotid, 1)[0] res = weather_dict[prev_slot] except: current_date = singletonTimeslot.getDate(time_slotid) res = weather_dict[current_date] return pd.Series([res[1]], index=['preweather'])
def find_prev_traffic(self, series, traffic_dict=None, pre_num=2): start_district_id = series.iloc[0] time_slotid = series.iloc[1] index = ['traffic' + str(i + 1) for i in range(pre_num)] res = [] prevSlots = singletonTimeslot.getPrevSlots(time_slotid, pre_num) for prevslot in prevSlots: try: res.append(traffic_dict[(start_district_id, prevslot)]) except: res.append(0) return pd.Series(res, index=index)
def find_prev_weather(self, time_slotid, weather_dict=None,): if self.is_first_record(weather_dict, time_slotid): return pd.Series([0], index=['preweather']) current_slot = time_slotid while(True): res = singletonTimeslot.getPrevSlots(current_slot, 1) current_slot = res[0] try: res = weather_dict[current_slot] return pd.Series([res[1]], index=['preweather']) except: pass return
def find_prev_weather(self, time_slotid, weather_dict=None,): if self.is_first_record(weather_dict, time_slotid): return pd.Series([0], index = ['preweather']) current_slot = time_slotid while(True): res = singletonTimeslot.getPrevSlots(current_slot, 1) current_slot = res[0] try: res = weather_dict[current_slot] return pd.Series([res[1]], index = ['preweather']) except: pass return
def find_prev_gap(self, row, pre_num=3, gap_dict=None): start_district_id = row.iloc[0] time_slotid = row.iloc[1] index = ['gap' + str(i + 1) for i in range(pre_num)] res = [] prevSlots = singletonTimeslot.getPrevSlots(time_slotid, pre_num) for prevslot in prevSlots: try: res.append(gap_dict[(start_district_id, prevslot)]) except: res.append(0) res = pd.Series(res, index=index) return res
def find_prev_gap(self, row, pre_num = 3, gap_dict = None): start_district_id = row.iloc[0] time_slotid = row.iloc[1] index = ['gap' + str(i + 1) for i in range(pre_num)] res = [] prevSlots = singletonTimeslot.getPrevSlots(time_slotid, pre_num) for prevslot in prevSlots: try: res.append(gap_dict[(start_district_id, prevslot)]) except: res.append(0) res =pd.Series(res, index = index) return res