# 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: utility/dumpload.py
# class DumpLoad:
#     def __init__(self, pickle_filepath):
#         self.pickle_filepath = pickle_filepath
#         dir_path = os.path.dirname(pickle_filepath)
#         if not os.path.exists(dir_path):
#             os.makedirs(dir_path)
#         
#         return
#     def load(self):
#         with open(self.pickle_filepath, 'rb') as handle:
#             dataset = pickle.load(handle)
#         return dataset
#     def isExisiting(self):
#         return os.path.exists(self.pickle_filepath) 
#     def run(self):
#         self.dump((np.arange(10), np.arange(20)))
#         print(self.load())
#         return
#     
#     def dump(self, dataset):
#         with open(self.pickle_filepath, 'wb') as f:
#             pickle.dump(dataset, f, pickle.HIGHEST_PROTOCOL)
#         return


from utility.datafilepath import g_singletonDataFilePath
from timeslot import singletonTimeslot
from exploredata import ExploreData
from time import time
from utility.dumpload import DumpLoad
from scipy.stats import mode
import pandas as pd
import os
            resDict[row['time_slotid']] = (index, row['weather'], row['temparature'], row['pm25'])
        for name, group in df.groupby('time_date'):
            resDict[name] = (-1, mode(group['weather'])[0][0], mode(group['temparature'])[0][0], mode(group['pm25'])[0][0])
            
       
        dumpload.dump(resDict)
        print "dump weather dict:", round(time()-t0, 3), "s"
        return resDict
    def process_all_df(self, df):
        self.add_timeid_col(df)
        self.add_timedate_col(df)
        self.sort_by_time(df)
        return
    def get_intial_colnames(self):
        return ['Time','weather','temparature', 'pm25']
    def load_weatherdf(self, dataDir):
        filename = dataDir + 'weather_data/temp/weather.csv'
        return pd.read_csv(filename, index_col= 0)
    def is_first_record(self, weather_dict, time_slotid):
        try:
            res = weather_dict[time_slotid]
            if (res[0] == 0):
                return True
        except:
            pass
        return False
    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

# 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: utility/dumpload.py
# class DumpLoad:
#     def __init__(self, pickle_filepath):
#         self.pickle_filepath = pickle_filepath
#         dir_path = os.path.dirname(pickle_filepath)
#         if not os.path.exists(dir_path):
#             os.makedirs(dir_path)
#         
#         return
#     def load(self):
#         with open(self.pickle_filepath, 'rb') as handle:
#             dataset = pickle.load(handle)
#         return dataset
#     def isExisiting(self):
#         return os.path.exists(self.pickle_filepath) 
#     def run(self):
#         self.dump((np.arange(10), np.arange(20)))
#         print(self.load())
#         return
#     
#     def dump(self, dataset):
#         with open(self.pickle_filepath, 'wb') as f:
#             pickle.dump(dataset, f, pickle.HIGHEST_PROTOCOL)
#         return


# Path: exploredata/weather.py
from utility.datafilepath import g_singletonDataFilePath
from timeslot import singletonTimeslot
from exploredata import ExploreData
from time import time
from utility.dumpload import DumpLoad
from scipy.stats import mode
import pandas as pd
import os

            resDict[row['time_slotid']] = (index, row['weather'], row['temparature'], row['pm25'])
        for name, group in df.groupby('time_date'):
            resDict[name] = (-1, mode(group['weather'])[0][0], mode(group['temparature'])[0][0], mode(group['pm25'])[0][0])
            
       
        dumpload.dump(resDict)
        print "dump weather dict:", round(time()-t0, 3), "s"
        return resDict
    def process_all_df(self, df):
        self.add_timeid_col(df)
        self.add_timedate_col(df)
        self.sort_by_time(df)
        return
    def get_intial_colnames(self):
        return ['Time','weather','temparature', 'pm25']
    def load_weatherdf(self, dataDir):
        filename = dataDir + 'weather_data/temp/weather.csv'
        return pd.read_csv(filename, index_col= 0)
    def is_first_record(self, weather_dict, time_slotid):
        try:
            res = weather_dict[time_slotid]
            if (res[0] == 0):
                return True
        except:
            pass
        return False
    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):