# Path: utility/datafilepath.py
# class DataFilePath:
#     def __init__(self):
#     def getOrderDir_Train(self):  
#     def getOrderDir_Test1(self):  
#     def getTest1Dir(self):
#     def getTest2Dir(self):
#     def getTrainDir(self):
#     def getGapCsv_Train(self):
#     def getGapCsv_Test1(self):
#     def getTestset1Readme(self):
#     def getTestset2Readme(self):
#     def getGapFilename(self):
#     def getGapPredictionFileName(self):
#     def getPrevGapFileName(self):
#     def get_dir_name(self, data_dir):


import pandas as pd
import numpy as np
import math
from datetime import datetime
from datetime import timedelta
from utility.datafilepath import g_singletonDataFilePath
                res.append(testDate + '-'+ str(slot))
        return res
    def generateSlotSet_0(self):
        testDates = self.generateTestDate_0()
        slots = [46,58,70,82,94,106,118,130,142]
        return self.generateSlotSet(testDates, slots)
    def generateSlotSet_1(self):
        testDates = self.generateTestDate_1()
        slots = [46,58,70,82,94,106,118,130,142]
        return self.generateSlotSet(testDates, slots)
    def generateTestDistrict(self):
        return [i+ 1 for i in range(66)]
    def generatePrediction_0(self):
        testSlots = self.generateSlotSet_0()
        df = pd.read_csv(g_singletonDataFilePath.getGapCsv_Train())
        df = df.loc[df['time_slotid'].isin(testSlots)]
        self.saveResultCsv(df, 'prediction_0.csv')
        #map 2016-01-22-1 to 2016-01-22-001
#         df['timeslotrank'] = df['time_slotid'].map(lambda x: "-".join(x.split('-')[:3] + [x.split('-')[-1].zfill(3)]))
#         df = df.sort_values(by = ['timeslotrank','start_district_id'])
#         df.to_csv('prediction_0.csv', columns=['start_district_id', 'time_slotid', 'gap'], header=None, index=None)
        return
    def saveResultCsv(self, df, filename):
        #map 2016-01-22-1 to 2016-01-22-001
        df['timeslotrank'] = df['time_slotid'].map(lambda x: "-".join(x.split('-')[:3] + [x.split('-')[-1].zfill(3)]))
        df = df.sort_values(by = ['start_district_id', 'timeslotrank'])
        df.to_csv(filename, columns=['start_district_id', 'time_slotid', 'gap'], header=None, index=None)
        return
    def generateActual_0(self):
        testSlots = self.generateSlotSet_0()

# Path: utility/datafilepath.py
# class DataFilePath:
#     def __init__(self):
#     def getOrderDir_Train(self):  
#     def getOrderDir_Test1(self):  
#     def getTest1Dir(self):
#     def getTest2Dir(self):
#     def getTrainDir(self):
#     def getGapCsv_Train(self):
#     def getGapCsv_Test1(self):
#     def getTestset1Readme(self):
#     def getTestset2Readme(self):
#     def getGapFilename(self):
#     def getGapPredictionFileName(self):
#     def getPrevGapFileName(self):
#     def get_dir_name(self, data_dir):


# Path: evaluation/evaluate.py
import pandas as pd
import numpy as np
import math
from datetime import datetime
from datetime import timedelta
from utility.datafilepath import g_singletonDataFilePath

                res.append(testDate + '-'+ str(slot))
        return res
    def generateSlotSet_0(self):
        testDates = self.generateTestDate_0()
        slots = [46,58,70,82,94,106,118,130,142]
        return self.generateSlotSet(testDates, slots)
    def generateSlotSet_1(self):
        testDates = self.generateTestDate_1()
        slots = [46,58,70,82,94,106,118,130,142]
        return self.generateSlotSet(testDates, slots)
    def generateTestDistrict(self):
        return [i+ 1 for i in range(66)]
    def generatePrediction_0(self):
        testSlots = self.generateSlotSet_0()
        df = pd.read_csv(g_singletonDataFilePath.getGapCsv_Train())
        df = df.loc[df['time_slotid'].isin(testSlots)]
        self.saveResultCsv(df, 'prediction_0.csv')
        #map 2016-01-22-1 to 2016-01-22-001
#         df['timeslotrank'] = df['time_slotid'].map(lambda x: "-".join(x.split('-')[:3] + [x.split('-')[-1].zfill(3)]))
#         df = df.sort_values(by = ['timeslotrank','start_district_id'])
#         df.to_csv('prediction_0.csv', columns=['start_district_id', 'time_slotid', 'gap'], header=None, index=None)
        return
    def saveResultCsv(self, df, filename):
        #map 2016-01-22-1 to 2016-01-22-001
        df['timeslotrank'] = df['time_slotid'].map(lambda x: "-".join(x.split('-')[:3] + [x.split('-')[-1].zfill(3)]))
        df = df.sort_values(by = ['start_district_id', 'timeslotrank'])
        df.to_csv(filename, columns=['start_district_id', 'time_slotid', 'gap'], header=None, index=None)
        return
    def generateActual_0(self):
        testSlots = self.generateSlotSet_0()

        df = pd.read_csv(g_singletonDataFilePath.getGapCsv_Train())